Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 29 Mar 2007 17:22 GMT
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?

What is the best approach for this? Any reference papers? Thanks a lot.
Kevin Spencer - 29 Mar 2007 19:41 GMT
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.

Signature

HTH,

Kevin Spencer
Microsoft MVP

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

> Hello, friends,
>
[quoted text clipped - 20 lines]
>
> What is the best approach for this? Any reference papers? Thanks a lot.
Andrew - 29 Mar 2007 21:12 GMT
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.

> 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.
Kevin Spencer - 30 Mar 2007 13:34 GMT
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

Signature

HTH,

Kevin Spencer
Microsoft MVP

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

> Thanks, Kevin.
>
[quoted text clipped - 28 lines]
>> can
>> reference the other forms and their data from the main form.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.