Home » Controls » How to select entire Row in List View
How to select entire Row in List View
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 'Controls - How to select entire Row in List View Option Explicit 'Add a ListView Control to your form. Const LVM_FIRST = &H1000 Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54 Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55 Const LVS_EX_FULLROWSELECT = &H20 Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Sub LVFullRowSelect(lstvw As ListView) Dim rs As Long rs = SendMessageLong(lstvw.hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0&, 0&) rs = rs Or LVS_EX_FULLROWSELECT Call SendMessageLong(lstvw.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0&, rs) End Sub Private Sub Form_Load() ListView1.ColumnHeaders.Add , , "Col1" ListView1.ColumnHeaders.Add , , "Col2" Dim itmx As ListItem Set itmx = ListView1.ListItems.Add(, , "Hello") itmx.SubItems(1) = "World" ListView1.ColumnHeaders.Add , , "Col1" ListView1.ColumnHeaders.Add , , "Col2" Set itmx = ListView1.ListItems.Add(, , "Hello") itmx.SubItems(1) = "World" ListView1.View = lvwReport 'Trigger the select entire row function LVFullRowSelect ListView1 End Sub |
Enjoy this article?
Filed under: Controls
Leave a comment