So you have a csv-list in a textfile and a listview. Fields are
Group,Column1,Column2,Column3,Column4,Column5
Example(All strings)
"Beginning","1","Quiet","Some text","Some other text","c:\...\image.jpg"
"Beginning","2","Quiet","Some text2","Some other text2","c:\...\image2.jpg"
"Middle","3","Quiet","Some text3","Some other text3","c:\...\image3.jpg"
"Middle","4","Running","Some text4","Some other text4","c:\...\image4.jpg"
Group is to be a listviewgroup. Column1 a listviewitem, Column2 the 1st subitem of Column1, Column3 the 2nd subitem of Column1, Column4 the 3rd subitem of Column1, Column5 the last subitem of Column1.
Group and Column2 are not unique, all other columns are unique.
What would be the most efficient way to
- read a csv-file list with that structure
- populate the listview
- write to the csv-file
What I tried:
ListViewGroup k = new ListViewGroup("group1");
ListViewGroup l = new ListViewGroup("group2");
ListViewGroup a = new ListViewGroup("group3");
listView1.Groups.AddRange(new ListViewGroup[] {a, k, l });
ListViewItem item1 = new ListViewItem("column1_1", 0);
item1.SubItems.Add("column2_1");
item1.SubItems.Add("column3_1");
item1.SubItems.Add("column4_1");
item1.SubItems.Add("column5_1");
item1.Group=k;
listView1.Items.Add(item1);
ListViewItem item2 = new ListViewItem("column1_2", 0);
...
As a basis. But this method makes automation hard. Especially when there are more groups being reused. So I am looking for a way this is normally done.