Showing posts with label listbox. Show all posts
Showing posts with label listbox. Show all posts

Wednesday, 10 September 2014

Loop through a List box

 
 To loop through a listbox try this
 
 Dim mcount As Integer
        mcount = ListBox3.Items.Count
        Do Until mcount = 0
            ListBox3.SelectedIndex = mcount - 1
            your variable  = ListBox3.SelectedItem
 
            mcount = mcount - 1
        Loop

Monday, 10 March 2014

Move Items up and down in Listbox


 
To move Items up and down in a listbox use the following code.
 
'Make sure our item is not the first one on the list.


'Move down    
If ListBox1.SelectedIndex > 0 Then

        Dim I = ListBox1.SelectedIndex - 1
        ListBox1.Items.Insert(I, ListBox1.SelectedItem)

        ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)

        ListBox1.SelectedIndex = I
    End If


 

'Move down

    'Make sure our item is not the last one on the list.

    If ListBox1.SelectedIndex < ListBox1.Items.Count - 1 Then

       'Insert places items above the index you supply, since we want

       'to move it down the list we have to do + 2

        Dim I = ListBox1.SelectedIndex + 2

        ListBox1.Items.Insert(I, ListBox1.SelectedItem)

        ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
        ListBox1.SelectedIndex = I - 1

    End If
Code taken from Dreamincode.net

Friday, 19 April 2013

Clear Bound List Box VB.NET





To clear a bound listbox you must remove the binding then clear the content

try this


 Me.ListBox1.DataSource = Nothing
        Me.ListBox1.Items.Clear()




VB.NET 2005 2008


Tuesday, 11 December 2012

Loop Through List box


Use this to Loop through a list box

Dim i As Integer = 0
            For i = 0 To listbox.Items.Count - 1
                Me.listbox3.SelectedIndex = i
                Me.textbox1.Text &= listbox3.Text
            Next

Multi Point USB Charger

  USB Plug Charger, 4-Port USB Fast Charger Plug with 33W Intelligent Quick Charge 3.0 Wall Charger, Multi USBPower Adapter UK Fast Charging...