A listview is moving on...

G

gsb58

Hi!

This saves data from column1 in a Listview to disk like: 2005-09-20.txt

I've come so far in my research:

Dim fs As New FileStream("C:\" &
MyCalendar.TodayDate.ToShortDateString() & ".txt",
FileMode.OpenOrCreate)

Dim sw As New StreamWriter(fs)
fs.Flush()
sw.Flush()
Dim r1 As Integer
For r1 = 0 To lstMyList.Items.Count - 1

sw.WriteLine(lstMyList.Items.Item(r1).Text)

Next

sw.Close()
fs.Close()

However, how am I about to cycle through the second column and write it
to the same textfile?

The listview has two columns. Column1 will hold time like:

07:00
07:30....etc

Column2 will hold text, so it will look like:

07:00 Remember to eat something
07:30 Get dressed

Hope anybody can give me a better understanding on this subject.

Me.Name
 
P

Peter Proost

Hi, this should help, in a listview with multicolumns the values are saved
as subitems of the mainitems you can access them like this:

For i As Integer = 0 To ListView1.Items.Count - 1
objWrite.WriteLine(ListView1.Items(i).SubItems(0).Text & " " &
ListView1.Items(i).SubItems(1).Text)
Next

hth Greetz Peter
 
C

Collin Bennett

Does it have to be text? If not, then serialize the complete control
using the BinaryFormatter to file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top