Load a usercontrol into a splitted panel

  • Thread starter Thread starter Vincent RICHOMME
  • Start date Start date
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....

}
}
 
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.
 
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.
 
Back
Top