|
-
Mar 30th, 2005, 11:35 AM
#1
Thread Starter
Frenzied Member
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,
Last edited by thegreatone; Mar 30th, 2005 at 12:42 PM.
Zeegnahtuer?
-
Mar 30th, 2005, 11:39 AM
#2
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
-
Mar 30th, 2005, 11:55 AM
#3
Thread Starter
Frenzied Member
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...
-
Mar 30th, 2005, 12:25 PM
#4
Thread Starter
Frenzied Member
Re: ListView Population...
Can anyone offer me any more help please ?
-
Mar 30th, 2005, 12:35 PM
#5
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
-
Mar 30th, 2005, 12:41 PM
#6
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|