Results 1 to 5 of 5
  1. #1
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed

    [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

  2. #2
    T0P-CENT's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    88
    Reputation
    14
    Thanks
    17
    My Mood
    Stressed
    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
    Last edited by T0P-CENT; 04-13-2011 at 08:32 AM.

  3. The Following User Says Thank You to T0P-CENT For This Useful Post:

    Lyoto Machida (04-13-2011)

  4. #3
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed
    Thanks! it worked

  5. #4
    sythe179's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    The internet
    Posts
    660
    Reputation
    15
    Thanks
    1,458
    My Mood
    Paranoid
    alv, instead of making new threads every hour or so, just add em to this one...
    starting to get around spamming...

  6. The Following User Says Thank You to sythe179 For This Useful Post:

    Lyoto Machida (04-13-2011)

  7. #5
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    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.