Lanc1988 Posted February 18, 2004 Posted February 18, 2004 Is it possible to hide the main form when another form is open? Example, is there a code I can place on my frmUpdater.vb form that will hide (not close) the main form window, then once the frmUpdater.vb form is closed it will make the main form visible again? Quote
sjn78 Posted February 18, 2004 Posted February 18, 2004 You may have this on a button click event on your main form. dim f as new frmUpdater me.visible = false ' Hides main form f.show ' Opens new form me.visble = true ' Shows main form once the new form is closed Quote
pendragon Posted February 18, 2004 Posted February 18, 2004 me.hide() f.ShowDialog() me.show() If you use f.show then when the form has been shown the program will continue executing the function and will show itself again. Quote
Lanc1988 Posted February 18, 2004 Author Posted February 18, 2004 i put the following under the button code: 'Run Updater Button 'This code makes it load the updater form Dim frmUpdater As New frmUpdater Me.Visible = False ' Hides main form frmUpdater.Show() ' Opens new form and then I tried putting the following on the Form_Load code for the Updater form: 'Displays Main Form once Updater is closed Me.Visible = True But im having a problem, the main form wont show when i close the updater, so where should the code to redisplay the main window be instead of in the Form_Load of the updater form? Quote
Lanc1988 Posted February 18, 2004 Author Posted February 18, 2004 i tried changing the code on the Updater form from Me.Visible to Form1.Visible and it says it requires an object reference. Quote
*Experts* mutant Posted February 18, 2004 *Experts* Posted February 18, 2004 Do you want to show frmUpdater as a dialog? If yes then simply pass in your main form as the first paramter into the ShowDialog method, and then from your frmUpdater you can access the form you passed in using the Owner property. If you don't want to show it as a dialog, then the best way would be to edit the constructor of your frmUpdater to accept an instance of your main form, assign the passed in instance to a variable and use it from there. Quote
Lanc1988 Posted February 19, 2004 Author Posted February 19, 2004 but all i want to happen is to just 'hide' the main form while a certain form (Updater) is open and then have the main form reappear when the Updater is closed. Quote
pendragon Posted February 19, 2004 Posted February 19, 2004 In your button code Dim frmUpdater As New frmUpdater Me.Hide() frmUpdater.ShowDialog() Me.Show() Quote
Lanc1988 Posted February 19, 2004 Author Posted February 19, 2004 thank you! :D it works very good. Quote
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.