Expand|Select|Wrap|Line Numbers
- ListView lvContent = new ListView();
- //Add the column header
- lvContent.Columns.Add("Col1");
- lvContent.Columns.Add("Col2");
- lvContent.Columns.Add("Col3");
- lvContent.Columns.Add("Col4");
- lvContent.Columns.Add("Col5");
Expand|Select|Wrap|Line Numbers
- char[] delim = new char[] {','};
- System.IO.StreamReader reader = new System.IO.StreamReader(fileName);
- string line;
- while ((line = reader.ReadLine()) != null)
- {
- String[] arr = line.Split(delim);
- lvi = new ListViewItem();
- for (int i = 0; i < arr.Length; i++) // arr.Length is always 5
- {
- lvi.SubItems.Add(arr[i]);
- }
- this.lvContent.Items.Add(lvi);
- }
Is there anything wrong with my code or it is the nature of CSV file?
Thanks