Read ListBox Up Down(Reorder ListBox: From bottom to top) - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

The following code is used to reorder listbox:
Ascending
Private Sub AscendingButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
 Handles AscendingButton.Click
        ListBox1.Sorted = True
End Sub

Descending
ListBox1.Sorted = True
        ListBox1.Sorted = False
        Dim i As Integer
        Dim count = ListBox1.Items.Count
        For i = ListBox1.Items.Count - 1 To 0 Step -1
            ListBox1.Items.Add(ListBox1.Items(i))
        Next
        For i = 0 To count - 1
            ListBox1.Items.RemoveAt(ListBox1.SelectedItem)
        Next
End Sub


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.