[Help] ListBoxes [solved]

Posts 1–3 of 3 · Page 1 of 1
[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

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()
Well I solved it but thanks
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Need help?