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

working with MDI form?

Status
Not open for further replies.

Timtoi

Programmer
Jul 27, 2005
5
0
0
CA
I have a MDI form and some child form inside.How to show only one child form into the MDI form. When I click to another child form the first one must be close. How can i do that
 
LostFocus event to unload it


Not explaining well.
- How the child forms are loaded in the mdi?
- There is only one child in mdi, and when you click new you want this to unload and a new child to be loaded? If so then mdi style is not for you. You won't ever have multiple document in mdi form
 
can you give me some sample using lostfocus event?
 
In the code window select Form from the top left dropdown. Select LostFocus or Deactivate from event dropdown next to it. In the block of code that appears type in Unload Me.
-Max
 
I'm not too sure that a lost focus event is the way to go - I'm doing something similar with my application and don't want the child to disappear just because the user clicked on the menu.
Instead, when you are going to open a new form, unload all forms in current view first, then go ahead and load the new form.
Ie: if using a menu that is called from the MDI parent:

Code:
' function to remove all child forms
Private sub Unload_Child()
dim f as Form
    for each f in Forms
       if f <> me then
           unload f
       end if
    next
end sub

' menu click event
Private sub mnu_NewForm_Click()
    'clear MDI main
    Unload_Child
    ' set new top and left for new form
    frmNewForm.Top = 0
    frmNewForm.Left = 0
    ' show form
    frmNewForm.show
end sub

I don't have vb with me, but I'm pretty sure the above will give you a good idea of what I was talking about.

V.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top