Results 1 to 3 of 3

Thread: ListView Control (simple Q)

  1. #1
    Guest
    If I have two columns, how can I add something to the listview in the following way:
    Code:
       COLUMN1          COLUMN2 '//<---------Column Headers
         TEXT1            TEXT2
         TEXT3            TEXT4
    HYKWIM (I use the report style of the ListView)

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    How about:
    Code:
        Dim lstItem As ListItem
        
        With ListView1
            .ColumnHeaders.Add , "Column1", "Column1"
            .ColumnHeaders.Add , "Column2", "Column2"
            Set lstItem = .ListItems.Add(1, "Text1", "Text1")
            lstItem.SubItems(.ColumnHeaders("Column2").SubItemIndex) = "Text2"
            Set lstItem = .ListItems.Add(2, "Text3", "Text3")
            lstItem.SubItems(.ColumnHeaders("Column2").SubItemIndex) = "Text4"
            
            Set lstItem = Nothing
        End With

  3. #3
    Guest
    Thanks QWERTY. It works fine for adding new items. But there is a problem. I can't select anything what is under the column2. I can select any item from column1, but when I click on "Text2" or "Text4" it doesn't get selected. How to change it? Thanks in advance.

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