Load a text file in a Listview

  • Thread starter Thread starter mrjaune
  • Start date Start date
M

mrjaune

Hi Everyone,
I try to load a text file into a listview.
Here is my text file:
10
"Babar"
9
6
15
"Robert"
3
7

I want:
Line 1 in column 1
Line 2 in column 2
Line 3 in column 3
Line 4 in column 4
Line 5 in column 1
Line 6 in column 2
Line 7 in column 3
Line 8 in column 4
etc...

I don't know how to do it ...
Please help me.

Rita
 
Hi Everyone,
I try to load a text file into a listview.
Here is my text file:
10
"Babar"
9
6
15
"Robert"
3
7

I want:
Line 1 in column 1
Line 2 in column 2
Line 3 in column 3
Line 4 in column 4
Line 5 in column 1
Line 6 in column 2
Line 7 in column 3
Line 8 in column 4
etc...

I don't know how to do it ...
Please help me.

Rita

Hi Rita,

I'am assuming you have the column headers or whatever defined in
designer mode...

Dim LItem As New ListViewItem
LItem = New ListViewItem

' Loop Through Data File
'First Column
LItem.Text = "Line1 in Data File"
'Add subitems
LItem.SubItems.Add("Line2 in Data File")
LItem.SubItems.Add("Line3 in Data File")
LItem.SubItems.Add("Line4 in Data File")
'continue with reading data file .... and adding to listview
columns
......
'Now post the first ListView Row With the Item And Sub-items
ListView1.Items.Add(LItem)

Hope this helps. Leo
 
Back
Top