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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDI Child Dialog form

Status
Not open for further replies.

Durkin

Programmer
Nov 6, 2000
304
GB
Does anyone know how to make a dialog form within an mdi parent? I want one mdi child to open up another mdi child but I don't want the user to be able to access the first form until they have closed the second. Using showdialog isn't the way I want to go because that opens a form that isn't an mdi child.

Durkin
 
A solution is to have a main form with menu, toolbar, statusbar etc and a set of MDI child forms. Let say the firts MDI child named LogonForm, the 2nd ConnectForm , SearchForm the 3rd , CalendarForm and so on.
Use Hide() and ShowDialog() for the child forms to show only the forms you want to the user and when one visible is closed you can decide which another will be visible.
For eaxmple :
The user click on Logon menu item then call LogonForm.ShowDialog() and hide other child forms. The user press Logon button on the LogonForm and when the logon is done , call Hide() for this the LogonForm and call ShowDialog() for the ConnectForm.
When the user click on Disconnect menu item, for example , you could have one or more child forms open and should not be visible to the user until the Logon menu item is selected again:
Iterate through all child form and call Hide() :

private void CloseChildren()
{
foreach(Form vForm in this.MdiChildren)
vForm.Hide();
}
When user select Exit just call ( I assume Dispose() overloaded)
Application.ExitThread(); or /and
Application.Exit();

-obislavu-




 
Hi obislavu, thanks for your time. I think I need to be a little more clear about what I need. This situation with the dialog form is only for one pair of forms. I want my users to be able to open multiple forms at the same time and even multiples of the same form. Just in one of my forms (so far) I want the user to be able to open a dialog form that they must close before returning to that form in particular because they must chose a value from the dialog form.
Regards,

Durkin
 
Yes, let be a CalendarForm (which encapuslate a MonthCalendar ) and you want it to be displayed every time from a given form , let say from a form named ResultForm (which encapsulates a grid) whenever the user click on a date column. The user cannot go anywhere until closes this child dialog.
So, in this case, in the ResultForm class have a member m_CalendarForm of the System.Windows.Forms.MonthCalendar class and when the user click on a given column, call m_CalendarFoem.ShowDialog(). It will stay open until the user press the Close button on the m_CalendarForm and when this happen e.g. button_Close() will call m_CalendarForm.Hide();

-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top