Mikecrosoft Posted January 6, 2004 Posted January 6, 2004 Hi, I'm making a MDI based application, but I have no clue on how to open one MDI Child 1 time only, I'm using Main Sub Startup mode, and I'm using the following code to show the Child: This code its into a menu item click, inside the MDI Parent Form Dim SelFrm as Form SelFrm = New frmChild SelFrm.SetParent = Me SelFrm.Show The problem is when I click the MenuItem a new form its opened instead of set the focus to the current one opened (if its an opened previously) Any help its good !! Thanks Mike Quote Mikecrosoft.Net
hog Posted January 6, 2004 Posted January 6, 2004 I had this problem and got round it by having a variable in the parent form which is set True when the child opens. The if it is True on subsequent clicks it does nothing. Remember to set to false on close tho:) Quote My website
Administrators PlausiblyDamp Posted January 6, 2004 Administrators Posted January 6, 2004 You could also hold the variable SelFrm at the MDI form level and check if it is nothing - if nothing then you need to create a new instance otherwise use the existing one. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Mikecrosoft Posted January 6, 2004 Author Posted January 6, 2004 Thanks my friends, all the ideas are good, but I forgot something, my program logic its usinf the SelFrm as a variable that opens the selected child form depending the Menu Item selected. Dim SelFrm as Form Select Case MenuItem.Text Case "Menu1" SelFrm = New Form1 Case "Menu2" SelFrm = New Form2 ...... End Select May be this is the wrong way but I need it like this. Thanks Quote Mikecrosoft.Net
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.