Slide Panel

Nanouk04 20 Reputation points
2023-05-09T16:58:28.4+00:00

I have two Panels. One has to go up and down and the other has to go down and up.

The first one works, but the second on goes like the first one.

Both sliding from the lower border. Only the first has to do that.

How can I get the second one working from the top border?

 Private Sub ElbowControl25_Click(sender As Object, e As EventArgs) Handles ElbowControl25.Click


        While PanelSide1.Height < 160 And PanelSide2.Height < 161
            PanelSide1.Height += 1
            PanelSide2.Height += 1
        End While
        Square7.Visible = True
        ELbow1.Visible = False
        Elbow2.Visible = False
        Elbow3.Visible = False
        Elbow4.Visible = False
        Elbow5.Visible = False
        Elbow6.Visible = False

        Square1.Visible = False
        Square2.Visible = False
        Square3.Visible = False
        Square4.Visible = False
    End Sub

    Private Sub Square7_Click(sender As Object, e As EventArgs) Handles Square7.Click
        While PanelSide1.Height > 82 And PanelSide2.Height > 80
            PanelSide1.Height -= 1
            PanelSide2.Height -= 1
        End While
        Square7.Visible = False
        ELbow1.Visible = True
        Elbow2.Visible = True
        Elbow3.Visible = True
        Elbow4.Visible = True
        Elbow5.Visible = True
        Elbow6.Visible = True

        Square1.Visible = True
        Square2.Visible = True
        Square3.Visible = True
        Square4.Visible = True
    End Sub
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,647 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,668 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 29,106 Reputation points Microsoft Vendor
    2023-05-10T06:43:33.21+00:00

    Hi @Nanouk04 , This can be achieved by changing the Location of PanelSide2 while setting its size.

    You can refer to the following code.

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            While PanelSide1.Height < 160 And PanelSide2.Height < 161
                PanelSide1.Height += 1
                PanelSide2.Height += 1
                PanelSide2.Location = New Point(PanelSide2.Location.X, PanelSide2.Location.Y - 1)
            End While
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            While PanelSide1.Height > 82 And PanelSide2.Height > 80
                PanelSide1.Height -= 1
                PanelSide2.Height -= 1
                PanelSide2.Location = New Point(PanelSide2.Location.X, PanelSide2.Location.Y + 1)
            End While
        End Sub
    

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful