Reading textfile into listview

Hi there people. I've got another question I hope you'll be able to help me with.
I've been keeping track of a few things and have been saving numbers to a text
file in a table type format.

An example:


Team Wins Losses Ties Games Played

Team 1 4 2 2
team 7 1 0 8
etc etc etc etc etc

All is ok saving it but now I'd like to view the data I've entered in a listview.

I know how to read it with streamreader and split the strings (using "\t" becase
I've made it tab delimited) but the thing is now, how do I make it know (the listview)
when a new line is to be added

My last approach I thought I could add the whole file into a string, split it to another
string[] with the "\t" separator, the go: for(int i=0; i < "The string Name";i++)
then listview.items.add(thestringIdea) then realized it would just keep adding on the same line!

Thanks for any advice,

Rob




Answer this question

Reading textfile into listview

  • JMBC

    this.listView1.BeginUpdate();

    while (sr.Peek() != -1)

    {

    this.listView1.Items.Add(new ListViewItem(sr.ReadLine().Split("\t")));

    }

    this.listView1.EndUpdate();


  • vijayaraghava

    Hey, thanks for the quick response, really appreciate it!

    Probably nice to get some really easy questions on this board isn't it! lol

    Rob



  • Reading textfile into listview