s1ckOh
Well-known member
If there is an easier way, please share.
VB.NET:
Sub MoveItemUp()
intStartIndex = ListBox1.SelectedIndex
intFinishIndex = intStartIndex - 1
Try
ListBox1.Items.Insert(intFinishIndex, ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(intStartIndex + 1)
ListBox1.SelectedIndex = intFinishIndex
Catch ex As Exception
MsgBox("You have reached the start of the list")
End Try
End Sub
Sub MoveItemDown()
intStartIndex = ListBox1.SelectedIndex
intFinishIndex = intStartIndex + 2
Try
ListBox1.Items.Insert(intFinishIndex, ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(intStartIndex)
ListBox1.SelectedIndex = intStartIndex + 1
Catch ex As Exception
MsgBox("You have reached the end of the list")
End Try
End Sub