Results 1 to 3 of 3

Thread: ListView Again

  1. #1
    Guest
    If I have two columns (Report Style) and some items added to the control using this code:
    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
    How would do it so when the user double clicks on the listview, I can add each column to a seperate textbox (from one line of course - I use fullrowselection kind of thing)
    To show it more visually:
    Code:
        Column1     Column2
          Text1       Text2
          Text3       Text4
    After the user doubleclicks on the first row my textboxs would look like this:
    Code:
    ------------------   -----------------------
    |   Text1        |   |      Text2          |
    ------------------   -----------------------
    I hope you know what I mean.

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Try this:

    Code:
    Private Sub Form_Load()
    Dim lstItem As ListItem
        
    
            Set lstItem = ListView1.ListItems.Add(, , "Text1")
            lstItem.SubItems(1) = "Text2"
            
            Set lstItem = ListView1.ListItems.Add(, , "Text3")
            lstItem.SubItems(1) = "Text4"
            
            Set lstItem = Nothing
     
    
    End Sub
    
    Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    
    Text1.Text = Item.Text
    Text2.Text = Item.SubItems(1)
    End Sub
    Mark
    -------------------

  3. #3
    Guest
    Thanks Mark!!!!! Almost what I was looking for (I changed it a little bit and it works perfectly).
    Thanks again

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