Anurag Gupta

Anurag Gupta

  • NA
  • 23
  • 0

how to divide application in panels?

Aug 1 2009 5:03 AM
hi......
i m making a window application in which i want to divide my form into 3 panels(left,right, and top)
in left panel i have tree view(with some nodes n childs), in top panel i have some pics
now i want that when i click on tree view node, so related form should be disply on right side panel(this thing i allready done )with the help of following code:

private void treeView1_AfterSelect_1(object sender, TreeViewEventArgs e)
{
switch (e.Node.Name)
{
case "Node1": embedForm(new Form2()); break;
case "Node2": embedForm(new Form3()); break;
case "Node3": embedForm(new Form4()); break;

// etc...
}
}
private void embedForm(Form frm)
{
// Remove existing controls
foreach (Control ctl in panel3.Controls) ctl.Dispose();
rightpanel.Controls.Clear();
// Whack <frm> to turn it into a child control
frm.FormBorderStyle = FormBorderStyle.None;
frm.TopLevel = false;
frm.Visible = true;
frm.Dock = DockStyle.Fill;
rightpanel.Controls.Add(frm);
}
}

In this i phase a problem that when i click on any node in tree view, it will show the form in right panel as well as in top panel, but i want to show this only in right panel. what i want is that left and top panel will remains same, only right panel change when i click on any node.
Can anyone tell me how can i do this?
kindly provide me code, if possible..!!

Answers (1)