articles

Home / DeveloperSection / Articles / Panel Control in VB.Net

Panel Control in VB.Net

Pushpendra Singh46281 11-Dec-2010

The Panel control is a container of other controls. The Panel control is displayed by default without any borders at run time.

How to use Panel control

Drag and drop Panel control from toolbox on the window Form.

Panel Control in VB.Net

Collection of control can be placed in side Panel.

Panel Control in VB.Net

Transparent Panel 

First set BackColor of Panel suppose you set green  then set  Form's TransparencyKey property to the same color as Panel's background color –red in this case.

Private Sub Form25_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'change back color of Panel
        Panel1.BackColor = Color.Red
        'set Form's TransparencyKey to the same color as Panel's back color
        Me.TransparencyKey = Color.Red
        'Me keyword provide a way to refer to the current instance of class, that is,the instance in which code is running
 
 End Sub

Now when you run the application then panel will be transparent.

Panel Control in VB.Net

 

Panel properties

BackColor:  Panel BackColor can be changed through BackColor property.

  Private Sub Form25_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'change panel backcolor
        Panel1.BackColor = Color.BlanchedAlmond
  End Sub

Panel Control in VB.Net

BorderStyle:  Get or set BorderStyle of Panel.

Private Sub Form25_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'set BorderStyle of panel
        Panel1.BorderStyle = BorderStyle.FixedSingle
End Sub

 

Panel Control in VB.Net

Visible:  You can hide all control inside panel through visible property of Panel. If you want to hide then set visible to false.

 Private Sub Form25_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'hide panel
        Panel1.Visible = False
 End Sub

Now when applications run then Panel will not be show.

Panel Control in VB.Net

 


Updated 26-Apr-2020

Leave Comment

Comments

Liked By