all groups > dotnet windows forms > march 2007 >
You're in the

dotnet windows forms

group:

What is the best approach to keep opened window form info?



What is the best approach to keep opened window form info? Andrew
3/29/2007 9:22:06 AM
dotnet windows forms: Hello, friends,

In Windows Form applicaitons, it is often that a form window may need to
interact with other form windows. For example, clicking on a command button
in one form may bring another form to foreground and display text/image
accordingly. Do we normally keep global refrences somewhere for each opened
form windows, so that it is possible for opened windows to interact with each
other? For example:

public static formCollection
{
public static frmWindow1 frm1;
public static frmWindow2 frm2;
public static frmWindow3 frm3;
}

Or, do we want each window form only to keep references to the opened forms
it may need individually?

Re: What is the best approach to keep opened window form info? Andrew
3/29/2007 1:12:02 PM
Thanks, Kevin.

If that is the case, I need to declare each opened form at Main form scope,
not in its method scope, right?

I saw sample source code like the follows, and once this form is
instantiated, it can no longer be referenced:

private void mainToolStripMenuItem_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;

frmWindow1 frm1= new frmWindow1 ();

frm1.Show();

Cursor = Cursors.Default;
}

)

Do you know any links to good reference papers on this? Thanks.


[quoted text, click to view]
Re: What is the best approach to keep opened window form info? Kevin Spencer
3/29/2007 2:41:19 PM
In a Windows Forms application, there is one form that is the main form of
the thread. Other forms are launched from this one. So, you need to declare
the other forms in the main form, but do NOT make them static. Then you can
reference the other forms and their data from the main form.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
Networking Components, Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

[quoted text, click to view]

Re: What is the best approach to keep opened window form info? Kevin Spencer
3/30/2007 8:34:29 AM
Remember that a Form is just another Control class. So, as long as your code
makes sure to clean it up (dispose) properly, it doesn't matter what scope
you declare it at. Here's a good reference for you:

http://www.syncfusion.com/faq/windowsforms/Default.aspx

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
Networking Components, Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

[quoted text, click to view]

AddThis Social Bookmark Button