September 2, 2002 - Creating a Panel with Controls
September 2, 2002 Creating a Panel with Controls Tips: September 2002
Yehuda Shiran, Ph.D.
|
Location
, Size
, Name
, and Anchor
.
panel1= new Panel;
panel1.Location= new Point(0,0);
panel1.Size= new System.Drawing.Size(300,300);
panel1.Name= "This is a Panel";
panel1.Anchor= AnchorStyles.Top | AnchorStyles.Left;
Anchoring the panel is not always important. It will only play a part if you place this form inside another window.
Once the Panel
control is ready, we can add all contained controls to the panel. Suppose we have a label, a text box, and a button:
panel1.Controls.Add(label1);
panel1.Controls.Add(textBox1);
panel1.Controls.Add(button1);
To learn more about JScript .NET and ASP.NET, go to Column 117, JScript .NET, Part XI: Creating Windows Forms.