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

How load user control into panel on split container in Win app?

P: n/a
I have a Windows app with a split container (SplitContainer1) that contains
two panels (Panel1, Panel2).

I would like to load a user control (utcMyTest) into Panel2 on form load.

Can someone please tell me the line(s) of code to do that?

Also, is there an easy/dynamic way to unload whichever user control is
already in there? I'm assuming only one can be in there at a time, right?

Thanks,
Ron
Feb 15 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try this:
Panel2.controls.add(utcMyTest)

to unload:
Panel2.controls.remove(utcMyTest)

---
Another way to load multiple controls is:
Panel2.controls.AddRange(new control() {MyArrayOfControls})

Hope this helps.
"Ronald S. Cook" <rc***@westinis.comwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
>I have a Windows app with a split container (SplitContainer1) that contains
two panels (Panel1, Panel2).

I would like to load a user control (utcMyTest) into Panel2 on form load.

Can someone please tell me the line(s) of code to do that?

Also, is there an easy/dynamic way to unload whichever user control is
already in there? I'm assuming only one can be in there at a time, right?

Thanks,
Ron

Feb 16 '07 #2

P: n/a
Ronald S. Cook wrote:
I have a Windows app with a split container (SplitContainer1) that contains
two panels (Panel1, Panel2).

I would like to load a user control (utcMyTest) into Panel2 on form load.
utcMyTest = New ....
Panel2.Controls.Add( utcMyTest )
Also, is there an easy/dynamic way to unload whichever user control is
already in there?
Just in case you manage to get more than one in there ...

For i As Integer = Panel2.Controls.Count - 1 To 0 Step -1
Panel2.Controls.Remove( Panel2.Controls.Item(i) )
Next

A For Each loop /might/ work, but you would be removing items from a
collection as you loop through it - generally not a good idea.

HTH,
Phill W.
Feb 16 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.