Listview - Selecting an entire row? 
Author Message
 Listview - Selecting an entire row?

I need to select an entire row within a ListView control.  I saw the answer
here about a month ago, but, unfortunately, that article is no longer on
the server.  Could somebody please explain the API calls needed to do this
again?

--
Greg Michealson

http://www.*-*-*.com/



Fri, 17 Dec 1999 03:00:00 GMT  
 Listview - Selecting an entire row?

Greg,

Quote:
> I need to select an entire row within a ListView control.

Here's the code I use. Note that it requires a newer version of
comctl32.dll, which is a system file.

Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, lParam As
Any) As Long
Private Const LVM_FIRST = &H1000
Private Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
Private Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
Private Const LVS_EX_FULLROWSELECT = &H20

Private Sub Form_Load()
    Dim i As Integer
    Dim itm As ListItem
    Dim dwStyle As Long

    'Report view
    ListView1.View = lvwReport
    'Add a couple of columns
    ListView1.ColumnHeaders.Add , , "Column 1"
    ListView1.ColumnHeaders.Add , , "Column 2"
    ListView1.ColumnHeaders.Add , , "Column 3"
    'Add some data to the list
    For i = 1 To 100
        Set itm = ListView1.ListItems.Add(, , "This is item " & CStr(i))
        itm.SubItems(1) = "More data"
        itm.SubItems(2) = "Still more data"
    Next i
    'Get current list view style
    dwStyle = SendMessage(ListView1.hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0,
ByVal 0&)
    'Set full row select style bit
    dwStyle = dwStyle Or LVS_EX_FULLROWSELECT
    'Set new list view style
    SendMessage ListView1.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ByVal
dwStyle
End Sub

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Fri, 17 Dec 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ListView - Select An Entire Row

2. How to select entire row in ListView ?

3. Select entire row in ListView

4. How to select entire row in Listview

5. How to select entire row in ListView ? - FullRowSelect

6. How to select entire row in ListView ?

7. Selecting entire row in Listview?

8. How to select entire row in listview control (VB5)

9. Listview: Selecting entire row

10. How to select the entire row in a listview using VB6- mscomctl32.ocx

11. Listview : how to Select the Entire Row ??

12. Select an entire row in the ListView-control

 

 
Powered by phpBB® Forum Software