articles

home / developersection / articles / panel control in c#.net

Panel Control in C#.Net

Pushpendra Singh 25.02 K 24-Jan-2011

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:

 private void 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:
private void frmPanel_Load(object sender, EventArgs e)
{
    //change back color of Panel
    panel1.BackColor = Color.CadetBlue;
}

 

Output: 
BorderStyle:  Get or set BorderStyle of Panel.


Example:

private void 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:


private void frmPanel_Load(object sender, EventArgs e)
{
         //hide panel
           panel1.Visible = false;
}


Now when application run then Panel will not show.

Output 

c# c# 
Updated 28-Aug-2020

Leave Comment

Comments

Liked By