|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Remove not hide User Control, posting againHi 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. "Mike TI" <sunset***@hotmail.com> schrieb This is a contradiction: Remove from memory .... show again.> 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. If you removed something from memory, you can not show it again because it does not exist anymore. > UserControl.Parent=Form.SplitContainer1.Panel2 Armin> UserControl.Dock=DockStyle.Fill > UserControl.Show() > . > . > UserControl.Hide() > > Thanks. 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. Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:ePo5jiyTGHA.4492@TK2MSFTNGP09.phx.gbl... > "Mike TI" <sunset***@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 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. Show quoteHide quote "Mike TI" <sunset***@hotmail.com> wrote in message news:%23xIiUryTGHA.1868@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.nospam@freenet.de> wrote in message > news:ePo5jiyTGHA.4492@TK2MSFTNGP09.phx.gbl... >> "Mike TI" <sunset***@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 > > 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 Show quoteHide quote "Mike TI" <sunset***@hotmail.com> schreef in bericht news:%23xIiUryTGHA.1868@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.nospam@freenet.de> wrote in message > news:ePo5jiyTGHA.4492@TK2MSFTNGP09.phx.gbl... >> "Mike TI" <sunset***@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 > > "Mike TI" <sunset***@hotmail.com> schrieb If you do not want to use Hide, you have to remove it from the container > 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. 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
DEADLINE! Please help!
need help on bitblt Installation Error: Application validation did not succeed. Unable to continue Object Reference not set an instance of an object Serializing custom properties on a BindingList. BackgroundWorker and 'freezing' application How program function keys (e.g. F1, F2) in Windows app? MouseMove event not firing set back ground image to stretch Custom Control Properties |
|||||||||||||||||||||||