Home > DeveloperSection > Articles > Panel Control in C#.Net

Panel Control in C#.Net


C# C# 
Ratings:
0 Comment(s)
 13825  View(s)
Rate this:

Panel Control in C#.Net

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.Panel Control in C#.Net

Collection of control can be placed in side Panel.

Panel Control in C#.Net

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 Control in C#.Net

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:

 

Panel Control in C#.Net

 

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

Panel Control in C#.Net

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

 

Panel Control in C#.Net


Don't want to miss updates? Please click the below button!

Follow MindStick