Come spostarsi all'interno di una lista in VB net : How to move around a list in VB net
Per spostarsi in una lista si usano le seguenti codici : To move through a list, the following codes are used:
Si usano 2 pulsanti ( sopra e sotto ) come in figura : 2 buttons are used (above and below) as shown in the figure:
Private Sub PictureBoxSU_Click(sender As Object, e As EventArgs) Handles PictureBoxSU.Click
'porta in su
If ListBoxFiles.SelectedIndex < 1 Then Exit Sub
Dim L As String ' ListViewItem
Dim Index As Int32
L = ListBoxFiles.SelectedItems(0)
Index = ListBoxFiles.SelectedIndices(0)
ListBoxFiles.Items.RemoveAt(Index)
ListBoxFiles.Items.Insert(Index - 1, L)
Move_ = True
ListBoxFiles.SelectedIndex = Index - 1
End Sub
Private Sub PictureBoxGIU_Click(sender As Object, e As EventArgs) Handles PictureBoxGIU.Click
'porta in giu
If ListBoxFiles.SelectedIndex > ListBoxFiles.Items.Count - 1 Then Exit Sub
If ListBoxFiles.SelectedIndex < 0 Then Exit Sub
Dim L As String ' ListViewItem
Dim Index As Int32
L = ListBoxFiles.SelectedItems(0)
Index = ListBoxFiles.SelectedIndices(0)
ListBoxFiles.Items.RemoveAt(Index)
ListBoxFiles.Items.Insert(Index + 1, L)
Move_ = True
ListBoxFiles.SelectedIndex = Index + 1