Mit diesem Snippet, können Listboxeinträge nach oben oder unten gescrollt werden.
Private Sub cmdUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUp.Click
Dim SaveEntryAfter As String
Dim SaveEntyBefore As String
If Len(Listbox.SelectedItem) > 0 And Listbox.SelectedIndex > 0 Then
SaveEntryAfter = Listbox.Items.Item(Listbox.SelectedIndex - 1)
SaveEntyBefore = Listbox.SelectedItem
Listbox.Items.Item(Listbox.SelectedIndex - 1) = SaveEntyBefore
Listbox.Items.Item(Listbox.SelectedIndex) = SaveEntryAfter
Listbox.SelectedItem = SaveEntyBefore
End If
End Sub
Private Sub cmdDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDown.Click
Dim SaveEntryBefore As String
Dim SaveEntyAfter As String
If (Len(Listbox.SelectedItem)) > 0 And Listbox.Items.Count > Listbox.SelectedIndex + 1 Then
SaveEntryBefore = Listbox.Items.Item(Listbox.SelectedIndex + 1)
SaveEntyAfter = Listbox.SelectedItem
Listbox.Items.Item(Listbox.SelectedIndex + 1) = SaveEntyAfter
Listbox.Items.Item(Listbox.SelectedIndex) = SaveEntryBefore
Listbox.SelectedItem = SaveEntyAfter
End If
End Sub
Kommentare zum Snippet