[Help] Select all items in a ListBox [solved]

Posts 1–5 of 5 · Page 1 of 1
[Help] Select all items in a ListBox [solved]
Code:
SaveFileDialog1.ShowDialog()
        Dim saver As New System.IO.StreamWriter(SaveFileDialog1.FileName)
        Dim valu1 As String
        valu1 = ListBox1.Items.Count - 1
        ListBox1.SetSelected(valu1, True)
        saver.Write(ListBox1.Items(valu1))
        saver.Close()
Im using that code but it jsut select the last item.. I need to make it to select all items in lsitbox
your code have a little mistake ,,
SetSelected(Index as integer, value as boolean)
index means like the number of the item
when u select valu1 which is eqaul to last item number it selectes the last item
so u will just have to do a simple loop
Code:
ListBox1.SelectionMode = SelectionMode.MultiExtended
 For i = 0 To ListBox1.Items.Count - 1
            ListBox1.SetSelected(i, True)
        Next
Thanks! it worked
alv, instead of making new threads every hour or so, just add em to this one...
starting to get around spamming...
Quote Originally Posted by *****179 View Post
alv, instead of making new threads every hour or so, just add em to this one...
starting to get around spamming...
Agree, Do it.
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us