Solved

Which forms are showed?

Posted on 2006-06-09
2
228 Views
Last Modified: 2010-04-16
Hi!
I have a question:
In mainform 's source code, how can I know which other forms are showed, and how can I control these forms from mainform, such as calling a method in each of these forms?

Plz help me!
Thank you very much.
0
Comment
Question by:tunhien
  • 2
2 Comments
 
LVL 1

Accepted Solution

by:
mrsreeraj earned 300 total points
ID: 16875571
Check this link out
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c4c.aspx

within MDI form use this code
===================
child form is MyChildForm

MyChildForm childForm = null;
    foreach(Form f in this.MdiChildren)
     {
          if(f is MyChildForm)
          {
               // found it
                childForm = (MyChildForm) f;
                break;
           }
      }
      if( childForm != null)
      {
           childForm.Show();
           childForm.Focus();
      }
      else
      {
           childForm = new MyChildForm();
           childForm.MdiParent = this;
           childForm.Show();
           childForm.Focus();
      }
 
0
 
LVL 1

Expert Comment

by:mrsreeraj
ID: 16875585
or u could use singleton pattern
example code is here
http://www.codeproject.com/csharp/singletonforms.asp
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now