user control menu

alaric

Well-known member
Joined
Oct 12, 2005
Messages
53
Programming Experience
Beginner
[SOLVED] user control menu

Hi,

i created an usercontrol menu structure. This userrcontrol has buttons for opening diffirent forms.

When opening the mainform the usercontrol is there. When I click a button for opening a new frm, it should close (hide) the main form.

So is there a way to hide/close a form from the buttons on the usercontrol.

I thought it should be done by figuring out what the act form is and close it??

please any hint is welcome
In my book (complete viual basic.NET) is nothing dedicated to this subject

thanks in advance
 
Last edited:
If the UserControl is on the form you want to hide then you would just call:
VB.NET:
Me.Parent.Hide()
Note that Hiding and Closing a form are two quite different things, so be clear about which one you want to accomplish.

JB: it's [ code] and [ /code] not [vbcode] and [/vbcode] john :p
 
Last edited by a moderator:
THANKS,

that's clear to me.
is there something to say about when to hide and when to dispose/close a form?

Thanks
A
 
If you Dispose a form or Close it, which implicitly Disposes it, then, for all intents and purposes, the form ceases to exist. You would Close a form if and when you don't want to use it anymore, or you intend to create a new instance if you do want to use it again. If you want to be able to show the same instance of the form again, then you would Hide it. In my opinion, you would only Hide a form if you know for a fact that you are going to redisplay it, or if there is a chance that you will redisplay it and you need it to be the same instance for some reason, like it contains some data you need to keep.
 
Back
Top