1

I want to hide and show the side panel in a beautiful, uninterrupted way You have used several methods, including changing the Panel width also use way to change the location

 `Increase the width


          `    For i = 0 To 100 Step 10

            Panel1.Width = i
            Application.DoEvents()
            Me.Refresh()
        Next`  
decrease the width

    For i = 100 To 0 Step -10
            Panel1.Width = i
        Next
the code to change location 
        hide panel

Do Until Panel1.Location.X = 1020
        Panel1.Location = New Point(Panel1.Location.X + 10, 60)
        Application.DoEvents()
        Me.Refresh()
    Loop

show panel

`Do Until Panel1.Location.X = 830
            Panel1.Location = New Point(Panel1.Location.X - 10, 60)
            Application.DoEvents()
            Me.Refresh()
        Loop`

`

All the methods you use are not fast in motion and Intermittent Is there a special library for moving stuff i use visual studio 2008 video for problem enter link description here

Abbas Mohammed
  • 65
  • 1
  • 12

2 Answers2

1

I use WPF instead of Windows Forms apps for nice looking animations, maybe you can give WPF a try. With WPF you can change opacity, position, width ... with animations, have a look at https://msdn.microsoft.com/de-de/library/ms752312(v=vs.110).aspx

Schnatti
  • 89
  • 5
0

After lot research I used the factor in the background worker and put the lagging code in it,this is complete code

 Dim slide = False  ' check slide state left or right
        Private Sub Roundbutton1_Click_1(sender As Object, e As EventArgs) Handles Roundbutton1.Click
                    CheckForIllegalCrossThreadCalls = False
                    BackgroundWorker1.RunWorkerAsync()   
                End Sub 

background worker code

Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
                         If slide Then
                        While sidepanel.Width > 100
                            If sidepanel.Width < 150 Then
                                Do Until sidepanel.Width <= 100 ' make some slow motion
                                    sidepanel.Width -= 5
                                    Threading.Thread.Sleep(5)
                                Loop
                                GoTo 10
                            End If
                            sidepanel.Width -= 25
                            Me.Refresh()
                        End While

                    Else
                        While sidepanel.Width < 250
                            If sidepanel.Width > 200 Then
                                Do Until sidepanel.Width >= 250  ' make some slow motion
                                    sidepanel.Width += 5
                                    Threading.Thread.Sleep(5)
                                Loop
                                GoTo 10
                            End If
                            sidepanel.Width += 25
                            Me.Refresh()
                        End While
                    End If
            10:     slide = Not slide
                      Me.Refresh() End Sub
Abbas Mohammed
  • 65
  • 1
  • 12