Results 1 to 2 of 2

Thread: listview

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Launceston, Tasmania, Australia
    Posts
    44

    Post

    my question is about the list view in the microsoft windows control 5 i think it is.

    i have 2 colums in my list view, but how do i write to the second column? to write to the listview this seems to work:

    ListView1.ListItems.Add , , "whatever"
    but if i do this:
    ListView1.ListItems.Add (2) , , "whatever"

    it still writes to the first column.

    someone told me to do this:

    listview1.ListItems.Item(2).ListSubItems.Add , , "Cya"

    but that does not work for me maybe because I am in vb5, so how do you actually enter something in the second column?

    thanx

    ------------------
    Mooose

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

    Post

    Columns after the first one are treated as SubItems. Here's an example:

    Code:
    Private Sub Command1_Click()
        Dim xListItem As ListItem
        Dim xColHeader As ColumnHeader
        Dim i As Integer
        
        With ListView1
            Set xColHeader = .ColumnHeaders.Add(, , "Column1")
            Set xColHeader = .ColumnHeaders.Add(, , "Column2")
            Set xColHeader = .ColumnHeaders.Add(, , "Column3")
        
            Set xListItem = .ListItems.Add(, , "First Value")
            'SubItems are 1 - based
            For i = 1 To .ColumnHeaders.Count - 1
                xListItem.SubItems(i) = "SubItem" & i & " value"
            Next
        End With
    End Sub
    ------------------

    Serge

    Senior Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819

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