How To Make A Drop-Down Effect In VB.NET

oh after a little bit time i am here to write a tutorial i am glad about it , this tutorial is about making a drop down effect in visual basic . net its pretty simple , lets make it

1 .open your most favorite visual studio 2008/2010

2 . create a new project and name it whatever you want

3 . add a button

4 . add a panel

5 .set the panel size to 426, 220

6 . set the form size to 466, 305

7 . make your form look like this


8 . double click your button and add this code


 If Panel1.Visible = True Then  ' Checks if panel1 is visible, if it is, run the code below.
            Button1.Text = "Drop Down"  ' Changes the text on the button to "Open Menu" because we are closing it.
            While Panel1.Height > 2  ' Run the code below while panel1's height is greater than 2.
                ' The reason I changed the height to 2 is because I want the panel's height to be 2 when it is closed.
                Panel1.Size = New Size(Panel1.Width, Panel1.Height - 1)  ' Subtract panel1's height by 1 each time.
            End While     ' Don't run the above code anymore!
            While Me.Height > 75   ' Run the code below while the form's (me) height is greating than 65.
                ' Again, the reason I changed the form's height to 65, is because that's how big it will be when the menu is closed.
                Me.Size = New Size(Me.Width, Me.Height - 2)     ' Subtract the form's height by 1 each time.
            End While     ' Don't run the above code anymore!
            Panel1.Visible = False    ' Make panel1 invisible.
        Else    ' If panel1 isn't visible, forget the above code and run the code below.
            Button1.Text = "Close Drop Down"  ' The rest is the same as above almost, so I wont explain it as much.
            While Panel1.Height < 230  ' Instead of 245, make it the size of your panel.
                Panel1.Size = New Size(Panel1.Width, Panel1.Height + 1)
            End While
            While Me.Height < 300   ' Instead of 321, make it the size of your form.
                Me.Size = New Size(Me.Width, Me.Height + 2)
            End While
            Panel1.Visible = True
        End If


9 . now set your form size to 466, 73

10 . now debug and it will work like this



Post a Comment

Note: Only a member of this blog may post a comment.