Dr_Michael
January 5th, 2000, 01:24 AM
How can I achieve the best way of looping through the contentents of a listview control in order to 'throw' all the data row, by row, to a rich text box? (in order to print them).
Thanx.
Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece
Chris Eastwood
January 5th, 2000, 02:42 AM
This should do it for you - I'm copying all the details into a huge string, but you can change that :
Dim li as ListItem
Dim iSubItems as Integer
Dim iCount as Integer
Dim sOut as string
'
' get the number of subitems - 1 because col 1 is the
' listitem text
'
iSubItems = ListView1.ColumnHeaders.Count - 1
'
sOut = ""
for Each li In ListView1.ListItems
sOut = sOut & "Key = " & li.Key & " Text = " & li.Text
for iCount = 1 to iSubItems
sOut = sOut & " SubItem(" & iCount & ") = " & li.SubItems(iCount)
next
sOut = sOut & vbCrLf
next
Debug.print sOut
'
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb