Click to See Complete Forum and Search --> : Listview
Hutty
Feb 2nd, 2000, 01:55 AM
I have a listview with 5 columns. I'm trying to split a string where there are spaces. Right now the data is all in column one, whereas, it should be split in all five columns. How can I split the string "sztemp" in the followin code so that it's in five columns? Thanks!
Dim xItem As ListItem
Set xItem = Form1.ListView1.ListItems.Add(Form1.ListView1.ListItems.COUNT + 1, , sztemp)
jpark
Feb 2nd, 2000, 03:14 AM
Assuming that the sztemp contains 5 strings that are seperated by space.(e.g sztemp = "Hello Hutty, How are you?")
This'll add 5 row items to column 1
==========================================
Dim xItem As ListItem
Dim i as integer
Dim ItemArr() as String
ItemArr = Split(sztemp)
For i = 0 to Ubound(ItemArr)
Set xItem = Form1.ListView1.ListItems.Add(Form1.ListView1.ListItems.COUNT + 1, , ItemArr(i))
Next
============================================
Or this'll add 5 column items to row 1
==========================================
Dim xItem As ListItem
Dim i as integer
Dim ItemArr() as String
ItemArr = Split(sztemp)
Set xItem = Form1.ListView1.ListItems.Add(Form1.ListView1.ListItems.COUNT + 1, , ItemArr(0))
For i = 1 to Ubound(ItemArr)
xItem.ListSubItems.Add xItem.ListSubItems.Count + 1, , ItemArr(i)
Next
============================================
Joon
Hutty
Feb 2nd, 2000, 03:45 AM
Joon,
The second one worked! Is it possible to add lines to the right or left in columns? Same as a grid. Thanks again!
Serge
Feb 2nd, 2000, 04:10 AM
If you used Split function and it worked, the you have VB6....If you have VB6 then all you have to do is right click the ListView and select properties. Make sure Grid Lines check box is checked. THAT'S IT.
------------------
Serge
Senior Programmer Analyst
sdymkov@microage.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Hutty
Feb 2nd, 2000, 04:15 AM
That was too easy Serge. Thanks!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.