Tuesday, May 5, 2009

Displaying Foms in Panels in Visual Studio .net

Visual studio comes with a very useful control named as splittercontrol.
This can be used to create different sections in the Winform application just like a Microsoft outlook. These sections can be configured at run time and a user can re size the panels.
******* Code hints ***************
//add a winform frm1.cs to the project
//declare a static SplitterPanel as shown:

public static SplitterPanel P1 = null;
// Add the following function.
public static void ShowWithinPanel(Form frm)
{
// frm is the instance of a form which is included in the same project and
// you want this form to appear insie the panel.

frm.TopLevel = false;// top level controls can not be added to the split container.
P2.Controls.Add(frm);
P2.Controls[frm.Name].Dock = DockStyle.Fill; // It will fill the panel
P2.Controls[frm.Name].Show();
}

- Abhinaw

No comments:

Post a Comment