473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

WinForms- Modal forms that call functions which change original fo

I have a form with a button.

public class FrmMain : System.Windows.Forms.Form
{
....
public ProgramPreferences myAppPreferences;
....
}

The button opens up a new modal form:
private void btn_CLick(object sender, System.EventArgs e)
{

myApp.Form2 newForm= new Form2();
eventForm.ShowDialog();
eventForm.Focus();
}

From the new form, I'd like be able to call a frmMain function that redraws
the original form. How can I do this? I'm not sure how to refer to the
original object that instantiated the current object I'm in. I tried using
passing the object as an argument in the constructor, but the methods I've
created don't show (all are declared public) Any thoughts?

Thanks very much!
Nov 16 '05 #1
2 4220
Patrick:

If you pass in the form for instance, it should be showing up - do you have
a property in the second form that's being set so you don't have any scope
issues and/or have you verified the type of the first form parameter
argument? My other guess if niether of these is the problem is that perhaps
you have a different namespace on the first form - but that would give you a
compile error so that's probably not it either
"Patrick" <Pa*****@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
I have a form with a button.

public class FrmMain : System.Windows.Forms.Form
{
...
public ProgramPreferences myAppPreferences;
...
}

The button opens up a new modal form:
private void btn_CLick(object sender, System.EventArgs e)
{

myApp.Form2 newForm= new Form2();
eventForm.ShowDialog();
eventForm.Focus();
}

From the new form, I'd like be able to call a frmMain function that redraws the original form. How can I do this? I'm not sure how to refer to the
original object that instantiated the current object I'm in. I tried using passing the object as an argument in the constructor, but the methods I've
created don't show (all are declared public) Any thoughts?

Thanks very much!

Nov 16 '05 #2
Create a delegate (event) in Form2 that will signal FrmMain that it's
time to call a method. Call it something like this:

myApp.Form2 newForm= new Form2();
newForm += new EventHandler(callingForm2);
eventForm.ShowDialog();
....
void callingForm2(object sender, EventArgs e) {
....
}
Patrick wrote:
I have a form with a button.

public class FrmMain : System.Windows.Forms.Form
{
...
public ProgramPreferences myAppPreferences;
...
}

The button opens up a new modal form:
private void btn_CLick(object sender, System.EventArgs e)
{

myApp.Form2 newForm= new Form2();
eventForm.ShowDialog();
eventForm.Focus();
}

From the new form, I'd like be able to call a frmMain function that redraws the original form. How can I do this? I'm not sure how to refer to the original object that instantiated the current object I'm in. I tried using passing the object as an argument in the constructor, but the methods I've created don't show (all are declared public) Any thoughts?

Thanks very much!


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael H | last post by:
I have a strange error occuring in my winforms app that I can't seem to find any fix for. With a button click I am launching something like the following: string url ="http://www.microsoft.com"...
4
by: Elhanan | last post by:
hi.. all a client of ours is considering to move from a dos application to windows desktop application. the application is for traveling agency, the database is rather large. their current...
0
by: Shamil Salakhetdinov | last post by:
Hi All, Have anybody seen somewhere techniques like the one described here: Automating Windows Applications http://www.thecodeproject.com/com/automatingwindowsapps.asp but for managed...
2
by: Mahesh Kumar.R | last post by:
I'm into designing an application in winforms but in near future my client may request the same thing in webforms. so (1) what are all the design guidelines and ways are there to migrate easily in...
1
by: Pieter | last post by:
Hi, In my application VB.NET 2005 application I placed a ReportViewer, and link it to a server-report: Me.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote...
4
by: 3Cooks | last post by:
I have a windows application written in Visual Basic 6.0 that is going to be redeveloped in dotNET. We are trying to decide if we should deploy using Webforms or Winforms and I need advice from...
1
by: Peter931 | last post by:
I have a winforms Application that should share some data via WEB-Services. Remoting is not possible for other reasons. How can this be done ? When the WEB-Service is hosted in IIS on the...
0
by: BigDave | last post by:
Hi all, I tried this question in the WinForms forum, but perhaps I'll have better luck here. We have an ASP.NET 2.0 web app which uses Profiles, and want to write a little WinForms app to...
5
by: Bit byte | last post by:
Can I use C# (Winforms) to design a website?. I am from C/C++ background but know nothing about Internet programming. My understanding of WebForms are that they are similar to WinForms in that...
23
by: raylopez99 | last post by:
Here I am learning WinForms and two months into it I learn there's a WPF API that is coming out. Is this WPF out yet, and is it a threat to WinForms, in the sense that all the library routines I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.