By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 1,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

A listview is moving on...

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

<gs***@hotmail.com> schreef in bericht
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Nov 21 '05 #2

P: n/a
Does it have to be text? If not, then serialize the complete control
using the BinaryFormatter to file.

gs***@hotmail.com wrote:
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

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.