By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,114 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

Remove not hide User Control, posting again

P: n/a
March 24, 2006

Hi all

I am new to VB.NET and am using VB.NET 2005.

I have an MDI form with a Split Container Control. On demand I am adding and
removing User Controls on Panel 2. I am using Show() and Hide(). It works
perfectly. The only thing is I would like to remove the User Control from
memory instead of hiding. I tried Dispose(), however then I cannot show this
user control again.

UserControl.Parent=Form.SplitContainer1.Panel2
UserControl.Dock=DockStyle.Fill
UserControl.Show()
..
..
UserControl.Hide()

Thanks.
Mar 24 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Mike TI" <su*******@hotmail.com> schrieb
March 24, 2006

Hi all

I am new to VB.NET and am using VB.NET 2005.

I have an MDI form with a Split Container Control. On demand I am
adding and removing User Controls on Panel 2. I am using Show() and
Hide(). It works perfectly. The only thing is I would like to remove
the User Control from memory instead of hiding. I tried Dispose(),
however then I cannot show this user control again.
This is a contradiction: Remove from memory .... show again.

If you removed something from memory, you can not show it again because it
does not exist anymore.
UserControl.Parent=Form.SplitContainer1.Panel2
UserControl.Dock=DockStyle.Fill
UserControl.Show()
.
.
UserControl.Hide()

Thanks.

Armin

Mar 24 '06 #2

P: n/a
I mean is it possible for me to show the user control again and again on
demand with the same behaviour as it was displayed for first time (firing
load event etc.) instead of using Hide() which probably is the same thing as
Visible=False.

Thank you.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
"Mike TI" <su*******@hotmail.com> schrieb
March 24, 2006

Hi all

I am new to VB.NET and am using VB.NET 2005.

I have an MDI form with a Split Container Control. On demand I am
adding and removing User Controls on Panel 2. I am using Show() and
Hide(). It works perfectly. The only thing is I would like to remove
the User Control from memory instead of hiding. I tried Dispose(),
however then I cannot show this user control again.


This is a contradiction: Remove from memory .... show again.

If you removed something from memory, you can not show it again because it
does not exist anymore.
UserControl.Parent=Form.SplitContainer1.Panel2
UserControl.Dock=DockStyle.Fill
UserControl.Show()
.
.
UserControl.Hide()

Thanks.

Armin

Mar 24 '06 #3

P: n/a
Mike,

Of course you only have to instance it from its class and add it to your
form again.

Dim myControl as New myUsercontrol.
me.controls.add(myControl)

And set than the right properties again.

I hope this helps,

Cor

"Mike TI" <su*******@hotmail.com> schreef in bericht
news:%2****************@TK2MSFTNGP09.phx.gbl...
I mean is it possible for me to show the user control again and again on
demand with the same behaviour as it was displayed for first time (firing
load event etc.) instead of using Hide() which probably is the same thing
as Visible=False.

Thank you.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
"Mike TI" <su*******@hotmail.com> schrieb
March 24, 2006

Hi all

I am new to VB.NET and am using VB.NET 2005.

I have an MDI form with a Split Container Control. On demand I am
adding and removing User Controls on Panel 2. I am using Show() and
Hide(). It works perfectly. The only thing is I would like to remove
the User Control from memory instead of hiding. I tried Dispose(),
however then I cannot show this user control again.


This is a contradiction: Remove from memory .... show again.

If you removed something from memory, you can not show it again because
it does not exist anymore.
UserControl.Parent=Form.SplitContainer1.Panel2
UserControl.Dock=DockStyle.Fill
UserControl.Show()
.
.
UserControl.Hide()

Thanks.

Armin


Mar 24 '06 #4

P: n/a
Of course you can. That's the whole rationale behind instantiating objects.

Just create an new instance of the component, set all the relevant
properties as required and hook up the event handlers as required and Bob's
your uncle.
"Mike TI" <su*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I mean is it possible for me to show the user control again and again on
demand with the same behaviour as it was displayed for first time (firing
load event etc.) instead of using Hide() which probably is the same thing
as Visible=False.

Thank you.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
"Mike TI" <su*******@hotmail.com> schrieb
March 24, 2006

Hi all

I am new to VB.NET and am using VB.NET 2005.

I have an MDI form with a Split Container Control. On demand I am
adding and removing User Controls on Panel 2. I am using Show() and
Hide(). It works perfectly. The only thing is I would like to remove
the User Control from memory instead of hiding. I tried Dispose(),
however then I cannot show this user control again.


This is a contradiction: Remove from memory .... show again.

If you removed something from memory, you can not show it again because
it does not exist anymore.
UserControl.Parent=Form.SplitContainer1.Panel2
UserControl.Dock=DockStyle.Fill
UserControl.Show()
.
.
UserControl.Hide()

Thanks.

Armin


Mar 24 '06 #5

P: n/a
"Mike TI" <su*******@hotmail.com> schrieb
I mean is it possible for me to show the user control again and
again on demand with the same behaviour as it was displayed for
first time (firing load event etc.) instead of using Hide() which
probably is the same thing as Visible=False.


If you do not want to use Hide, you have to remove it from the container
control, call Dispose and remove remaining references. Whenever you need a
control again, you can create it, set it's properites and add it to the
container (TheContainer.Controls.Add). If you have a variable declared using
"WithEvents" that was previously pointing to the former control, you can
assign the new control to this variable again and all event procedures will
be working just like with the former control. If you don't have a WithEvents
variable, use the AddHandler statement to attach event handlers to the new
control.
Armin

Mar 24 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.