Results 1 to 5 of 5

Thread: Listview

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    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)

  2. #2
    Member
    Join Date
    Jan 1999
    Location
    Garden Grove, CA, Orange
    Posts
    55

    Post

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    Joon,

    The second one worked! Is it possible to add lines to the right or left in columns? Same as a grid. Thanks again!

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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
    [email protected]
    [email protected]
    ICQ#: 51055819

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    That was too easy Serge. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width