ListView Population... [resolved]
Ok, the following code, in theory should work... but in fact it doesn't what is wrong ?
VB Code:
Private Sub Command1_Click()
CD.Filter = "Text Files (*.txt)|*.txt"
Dim strData As String
Dim astrDataItem() As String
On Error Resume Next
'Open text file and split by :'s
CD.ShowOpen
If CD.FileName = "" Then
Else:
Open CD.FileName For Input As #1
Do Until EOF(1)
Line Input #1, strData
astrDataItem = Split(strData, ":")
ListView1.ListItems.Add 1, , astrDataItem(0)
ListView1.ListItems.Add 2, , astrDataItem(1)
Loop
Close #1
End If
End Sub
CD = CommonDialog control
Any Help would be greatly appreciated,
Re: ListView Population...
A couple of slight modifications...
VB Code:
'create a list item to use with your list view
Dim lvwItem As ListItem
Set lvwItem = ListView1.ListItems.Add 'etc
'use subitems for adding to other columns in the same row
lvwItem.SubItems(1) = 'etc
Re: ListView Population...
This doesn't seem to work, no matter what i try... it just adds a blank for the first column, and then the second split data to the second column...
Re: ListView Population...
Can anyone offer me any more help please ?
Re: ListView Population...
I assume your data looks something like this.
one:two:three
four:five:six
If so then you may have your columns, etc set up some place else but this works.
VB Code:
Private Sub Command1_Click()
Dim clmX As ColumnHeader
Dim itmX As ListItem
Set clmX = ListView1.ColumnHeaders.Add(, , "1st", ListView1.Width / 3)
Set clmX = ListView1.ColumnHeaders.Add(, , "2nd", ListView1.Width / 3)
Set clmX = ListView1.ColumnHeaders.Add(, , "3rd", ListView1.Width / 3)
ListView1.View = lvwReport
CD.Filter = "Text Files (*.txt)|*.txt"
Dim strData As String
Dim astrDataItem() As String
On Error Resume Next
'Open text file and split by :'s
CD.ShowOpen
If CD.FileName = "" Then
Else:
Open CD.FileName For Input As #1
Do Until EOF(1)
Line Input #1, strData
astrDataItem = Split(strData, ":")
Set itmX = ListView1.ListItems.Add(, , astrDataItem(0))
itmX.SubItems(1) = astrDataItem(1)
itmX.SubItems(2) = astrDataItem(2)
Loop
Close #1
End If
End Sub
Re: ListView Population...
Martin is a god for furthur explaining that :)
Thanks Hack :)
Pos Rep.... :)