The Panel control is similar to the GroupBox control; however,
only the Panel control can have scroll bars, and only the GroupBox control
displays a caption.
How to use Panel Control
Drag and drop Panel control from toolbox on the window Form.
Collection of control can be placed in side Panel.
Transparent Panel
First set BackColor of Panel suppose you set red then set Form's TransparencyKey property to the same color as Panel's background color –red in this case.
Example:
privatevoid frmPanel_Load(object sender, EventArgs e)
{
//change back color of Panel
panel1.BackColor = Color.Red;
//set Form's TransparencyKey to the same color as Panel's back color
this.TransparencyKey= Color.Red;
}
Now panel will be transparent when application run.
Panel Properties
BackColor: Panel BackColor can be changed through BackColor property.
Example:
privatevoid frmPanel_Load(object sender, EventArgs e)
{
//change back color of Panel
panel1.BackColor = Color.CadetBlue;
}
Output:
BorderStyle: Get or set BorderStyle of Panel.
Example:
privatevoid frmPanel_Load(object sender, EventArgs e)
{
//Set Border style of Panel
panel1.BorderStyle = BorderStyle.Fixed3D;
}
Output
Visible: You can hide all control inside panel through visible property of Panel. If
you want to hide then set visible to false.
Example:
privatevoid frmPanel_Load(object sender, EventArgs e)
{
//hide panel
panel1.Visible = false;
}
Now when application run then Panel will not show.
Leave Comment
2 Comments
View All Comments