20 November 2009

How to Embed a Windows Form in Another Control

If you have to embed a windows form in another control say a tab page, panel, groupbox etc. then you have to set the TopLevel property of the form to false and define its parent control and couple of other properties also to give it desired feel.
For example:-


Form1 objForm = new Form1();
Form1.TopLevel = false;
Form1.ControlBox = false;
Form1.FormBorderStyle = FormBorderStyle.None;
Form1.Dock = DockStyle.Fill;
Form1.Parent = this.pnlParent;


Dim objForm As New Form1()
Form1.TopLevel = False
Form1.ControlBox = False
Form1.FormBorderStyle = FormBorderStyle.None
Form1.Dock = DockStyle.Fill;
Form1.Parent = Me.pnlParent

No comments:

Post a Comment