Results 1 to 2 of 2

Thread: ListView Question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Posts
    135

    Thumbs up

    Hi There,
    I have a listview object and want to know 3 things.. With my listview object i have 3 columns. Is there a way to stop the columns from being resized? Also is there a way to find out which item (row) is selected? Also is there a way to find out when an row is selected, all the data from the columns that are on the row? If you can help me it would be great! Thanks!

  2. #2
    Lively Member
    Join Date
    Mar 2000
    Posts
    87
    Not sure about locking columns but for the other two try this

    Code:
    Private Sub Command1_Click()
        
        Dim i                   As Integer
        Dim iColumnCount        As Integer
        Dim sRowText            As String
        
        'Check if a row is selected
        If Not ListView1.SelectedItem Is Nothing Then
            
            'Subtract 1 because first column is the text field
            iColumnCount = ListView1.ColumnHeaders.Count - 1
            
            sRowText = ListView1.SelectedItem.Text
            
            'Get data from each subitem
            For i = 1 To iColumnCount
                sRowText = sRowText & ListView1.SelectedItem.SubItems(i)
            Next i
            
            MsgBox "Text in select row: " & sRowText
        Else
            MsgBox "No row selected"
        End If
    
    End Sub

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