Load a usercontrol into a splitted panel

V

Vincent RICHOMME

Hi,

I have a splitter with two panels, on the right panel I want to display
different user controls. How can I do ?


private void treeView1_BeforeSelect(object sender,
TreeViewCancelEventArgs e)
{
string strTag = e.Node.Tag.ToString();

if (strTag == "RemoteHelp")
{
//this.splitContainer....

}
}
 
S

Stoitcho Goutsev \(100\)

Vincent,

Use Panel1 and Panel2 properties to add the user control to one of the
splitter container panels.
Once you get the panel add the user control to its Controls collection.
 
N

Norman Yuan

If you want to do this programmaticlly, then

//Create an instance of the UserControl
MyUserControl ctl=new MyUserControl();

//Set usercontrol's properties
......

//Add the usercontrol to splitContainer's rignt panel
this.splitContainer1.Panel2.Controls.Add(ctl);

You may want to remove previous controls on the panel, or change their
visibility.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top