Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Child Forms in Windows Forms

Status
Not open for further replies.

smoothcoder

Programmer
Sep 24, 2002
19
RO
Hi there!

I use to code in Visual C++ 6.0 with MFC; recently I developed an app, dialog based, with the following features:
- a master dialog with an Outlook style menu on the left side; the menu has buttons that link to some modules; each module resides in a child dialog that is hidden until the module button is pushed; thus the child dialogs sit one on top of the others, being all hidden until the module is invoked; my questions are: How could I make this architecture in Windows Forms? How to make a form the child of another form? Until now I saw that a form can be either modal or modeless; and whatever I'd choose, the form would appear popped-up, which I don't like; I want the form stuck to its parent form. Can you give me a hint?
Sorry for my poor English :)

Thanks in advance, you all!

 
That is possible using Forms more easy than in C++6.0. A form has the MdiParent property that allow you to build the hierarchy and use Hide(), Show() methods to make visible.
Your code can decide which one is active and also which controls, menus etc are visible/enabled/disabled on each form.
public class MainForm : System.Windows.Forms.Form
public class ResultsForm : System.Windows.Forms.Form
public class LogOnForm : System.Windows.Forms.Form
...
If you are in the MainForm class:
m_LogOnForm = new LogOnForm();
m_LogOnForm.MdiParent = this;
m_ResultsForm= new ResultsForm();
m_ResultsForm.MdiParent=m_LogOnForm;

Example, the LogOnForm is displayed when some conditions occurs in the main form.
The ResultForm is not displayed until the username/password text boxes are fiiled and the logon was successful. When that occurs you could hide the LogOnForm and show the ResultForm with the results.

-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top