This tutorial will teach you how to create a sliding panel in vb.net.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to
File, click
New Project, and choose
Windows Application.
2. Next, add four LinkLabel name
LinkLabel1 and
LinkLabel2 that holds the Panel1 and Panel2, respectively, and
linkPanel1 and
linkPanel2 to show the Panels. Then Panel1 and Panel2 that will hold any objects from the toolbar. You must design your interface like this:
3. Now, we will code our program.
We will declare the variables as boolean if it was clicked.
Dim bln1, bln2 As Boolean
We will create a sub procedure named lbl1() and lbl2() for showing of panels with the condition variables declared as Boolean.
lbl1 procedure shows the sliding effect of Panel1.
Private Sub lbl1()
Timer1.Enabled = True
If bln1 = False Then
bln2 = False
bln1 = True
Else
bln1 = False
End If
End Sub
lbl2 procedure shows the sliding effect of Panel2.
Private Sub lbl2()
Timer2.Enabled = True
If bln2 = False Then
bln1 = False
bln2 = True
Else
bln2 = False
End If
End Sub
Have this code below for Timer1, to have a sliding panel for Panel1. The twist here is to increment and decrement the height of the Panel1 and used the bln1 to trigger to slide.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Panel2.Height = 0 Then
If bln1 = True Then
If Panel1.Height < 166 Then
Panel1.Height = Panel1.Height + 5
End If
Else
If Panel1.Height > 0 Then
Panel1.Height = Panel1.Height - 10
End If
End If
End If
End Sub
Same goes for Timer2 for the Panel2 and bln2 to trigger to slide.
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Panel1.Height = 0 Then
If bln2 = True Then
If Panel2.Height < 290 Then
Panel2.Height = Panel2.Height + 5
End If
Else
If Panel2.Height > 0 Then
Panel2.Height = Panel2.Height - 10
End If
End If
End If
End Sub
Output:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:
[email protected]
Add and Follow me on Facebook:
https://www.facebook.com/donzzsky
Visit and like my page on Facebook at:
https://www.facebook.com/BermzISware