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

    [Help] ListBoxes [solved]

    Code:
    SaveFileDialog1.ShowDialog()
            Dim saver As New System.IO.StreamWriter(SaveFileDialog1.FileName)
            ListBox1.SelectionMode = SelectionMode.MultiExtended
            For i = 0 To ListBox1.Items.Count - 1
                ListBox1.SetSelected(i, True)
                saver.Write(ListBox1.Items(i))
            Next
            saver.Close()
    This Is my code to save a file of a listbox but when i open it, it just put me all together
    Code:
    (File1File2File2File4...)
    and I want it makes
    Code:
    File1
    File2
    File3
    File4
    And also I have an problem I need to make when u click a item of Listbox1 its also selected on lsitbox2
    thanks
    Last edited by Jason; 04-14-2011 at 08:58 PM.

  2. #2
    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

    For the second question:
    On the event SelectedIndexChanged (of the first listbox ) you do something like:

    ListBox2.SelectedItem = ListBox1.SelectedItem

    But this is only if the other listbox contains the same itens..Or you ill get a error..

    Now for the first part..


    Code:
    SaveFileDialog1.ShowDialog()
            Dim saver As New System.IO.StreamWriter(SaveFileDialog1.FileName)
            ListBox1.SelectionMode = SelectionMode.MultiExtended
            For i = 0 To ListBox1.Items.Count - 1
                ListBox1.SetSelected(i, True)
                saver.Write(ListBox1.Items(i) & vbNewline) ' ADD & vbNewLine =)
            Next
            saver.Close()
    Last edited by Jason; 04-14-2011 at 08:59 PM.

  3. #3
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed
    Well I solved it but thanks