Moving between forms in VB.NET

  • Thread starter Thread starter Steven Thomas
  • Start date Start date
S

Steven Thomas

Ok, I am a newbee at vb.net and I have written an application with
multiple forms. I have created a form named frmbase with all other
forms are inherited from. frmbase has my menu on it. I have set
frmbase as the startup form. This all works great, however when I go
to form 2 I get a new window, and I would like for it to stay in the
same window that frmBase was in so I don't have lots of windows open
as a user is working.

Can someone point in the right direction to do this?

Thanks
 
* (e-mail address removed) (Steven Thomas) scripsit:
Ok, I am a newbee at vb.net and I have written an application with
multiple forms. I have created a form named frmbase with all other
forms are inherited from. frmbase has my menu on it. I have set
frmbase as the startup form. This all works great, however when I go
to form 2 I get a new window, and I would like for it to stay in the
same window that frmBase was in so I don't have lots of windows open
as a user is working.

Instead of designing forms, design usercontrols that are dynamically
instantiated/removed from the form.
 
Sounds good but I have about 20 forms built and working. Is there not a
better way to do this? If not is there and easy way to covert my forms
to controls?



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Sounds good but I have about 20 forms built and working. Is there not a
better way to do this? If not is there and easy way to covert my forms
to controls?

One method is to open the forms inside the main form. In the main form,
add a panel to hold the other forms.

For each of the other forms, set their border style to None.

Then to load the form into the panel, do something like this (check syntax)

Private Sub LoadFormIntoPanel()
Dim MyForm2 as New Form2
MyForm2.Size = pnlContent.Size
MyForm2.TopLevel = False
MyForm2.Parent = pnlContent
MyForm2.Show
End Sub

This code will show the form inside the panel. Be sure that, as you load
and unload forms, you dispose of them properly, etc.

This should give you some ideas. I don't know if it's better, but you wont
have to change your forms.
 
Chris
Thanks for then info. It seems simple enough. However I got the
first form to load in the panel. Then how do I close it and load the
second. I don't seem to be able to determine which form is loaded and
how to close it?
 
Back
Top