У меня есть пример, который я только что сделал, но он грязный, потому что у меня не было времени, чтобы он выглядел лучше:
Private _current As Panel
Private _forms As New List(Of Panel)
Public ReadOnly Property Current() As Panel
Get
Return _current
End Get
End Property
Public Property Forms() As List(Of Panel)
Get
Return _forms
End Get
Set(ByVal value As List(Of Panel))
_forms = value
End Set
End Property
Public Sub GoToPanel(panel As Panel)
Dim panindex As Int16 = Forms.IndexOf(panel)
Dim diff As Int16 = panindex - CurrentIndex
Select Case diff
Case Is < 0
For i As Int16 = CurrentIndex To panindex + 1 Step -1
Dim pan As Panel = Forms(i)
Dim pan2 As Panel
Dim existp As Boolean = True
If i - 1 < 0 Then
existp = False
pan2 = Nothing
Else
pan2 = Forms(i - 1)
pan2.Location = New Point(Width, 0)
End If
For x = pan.Location.X To -Width Step -5
pan.Location = New Point(x, 0)
If existp Then
pan2.Location = New Point(pan2.Location.X - 5, 0)
End If
Threading.Thread.Sleep(10)
Next
Next
Case Is > 0
For i As Int16 = CurrentIndex To panindex - 1 Step 1
Dim pan As Panel = Forms(i)
Dim pan2 As Panel
Dim existp As Boolean = True
If i + 1 > Forms.Count Then
existp = False
pan2 = Nothing
Else
pan2 = Forms(i + 1)
pan2.Location = New Point(-Width, 0)
End If
For x = pan.Location.X To Width Step +5
pan.Location = New Point(x, 0)
If existp Then
pan2.Location = New Point(pan2.Location.X + 5, 0)
End If
Threading.Thread.Sleep(10)
Next
Next
End Select
_current = panel
End Sub
Public ReadOnly Property CurrentIndex() As Int16
Get
Return Forms.IndexOf(_current)
End Get
End Property
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
Dim t As Threading.Thread = New Threading.Thread(AddressOf GoToPanel)
t.Start(Panel2)
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim t As Threading.Thread = New Threading.Thread(AddressOf GoToPanel)
t.Start(Panel1)
'GoToPanel(Panel1)
End Sub
Private Sub Form1_Resize(sender As System.Object, e As System.EventArgs) Handles MyBase.Resize
For Each p In Forms
If p.Equals(_current) Then
p.Width = Width
p.Height = Height
Else
If p.Location.X > 0 Then
p.Location = New Point(Width, 0)
End If
End If
Next
End Sub
Примечание:
этот код зависит от индексакаждой панели, поэтому вы должны использовать ту же индексацию, что и в форме.это только один способ скольжения, но вы можете изменить код для большего количества опций.Я надеюсь, что это сработает.для получения дополнительной информации, пожалуйста, прокомментируйте.