buttons to slide a ListBox's multiple selection up or down in Visual Basic .NET

Started by nandagopal, May 20, 2009, 07:11 PM

Previous topic - Next topic

nandagopal

To slide the selections up, loop through the items and use SetSelected to give each item the same selected value as the one below it.

To slide the selections down, loop through the items and use SetSelected to give each item the same selected value as the above following it.


Private Sub btnUp_Click(...) Handles btnUp.Click
    For i As Integer = 0 To lstAnimals.Items.Count - 2
        lstAnimals.SetSelected(i, lstAnimals.GetSelected(i _
            + 1))
    Next i
    lstAnimals.SetSelected(lstAnimals.Items.Count - 1, _
        False)
End Sub

Private Sub btnDown_Click(...) Handles btnDown.Click
    For i As Integer = lstAnimals.Items.Count - 1 To 1 Step _
        -1
        lstAnimals.SetSelected(i, lstAnimals.GetSelected(i _
            - 1))
    Next i
    lstAnimals.SetSelected(0, False)
End Sub



dhoni

this program is very useful to me
it gives more information
this program use for button to slide listbox multiplemselection up or down
this program is use in vb.net