In vb6 I installed in my computer it has microsoft windows common controls 5.0(sp2).I want to know how to have full row select option in listview component.how can i select full row at listview.in listview properties there is no fullrowselection check box.it has only 5 chechboxes.

Recommended Answers

All 4 Replies

Try the following code or give us more information...

listView1.Items(0).Selected = True

To select an entire row -

Private Sub Command1_Click()
    ListView1.MultiSelect = True
    For a = 1 To 10        
    ListView1.ListItems.Item(a).Selected = True
    Next
    ListView1.SetFocus
End Sub

Private Sub Form_Load()
    For a = 1 To 20
    ListView1.ListItems.Add , , a
    Next
End Sub

Do not forget to set HideSelection property to False

I did what you said.It works.but what I want is not that.what I want is..
in my listview there are 3 column headers as "code", "description" and "price".At listview properties view= 3-lvwReport.

private sub form_load()
listview1.listitem.add,,111
listview1.listitem(listview1.listitem.count).subitem(1)="apple"
listview1.listitem(listview1.listitem.count).subitem(2)="100"
listview1.listitem.add,,222
listview1.listitem(listview1.listitem.count).subitem(1)="mango"
listview1.listitem(listview1.listitem.count).subitem(2)="200"
endsub

when run the form and click code 111,I want to select 111,apple and 100 the entire row.please help.

First, your code is not running. You missing 's' in every ListItems and SubItems statements.

Second, As default you can't select entire rows. It's because version 5.0 (SP2) does not support it.
but if you use version 6.0, your listview will able to do that with set FullRowSelect = true.
In your case you can SendMessage to add this behavior :

Private Declare Function SendMessage Lib "user32" Alias _
        "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _
        wParam As Long, lParam As Any) As Long

Const LVS_EX_FULLROWSELECT = &H20
Const LVM_FIRST = &H1000
Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + &H37
Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + &H36


Private Sub Form_Load()
'Using api function
Dim lStyle As Long
lStyle = SendMessage(ListView1.hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
lStyle = lStyle Or LVS_EX_FULLROWSELECT
Call SendMessage(ListView1.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ByVal lStyle)


ListView1.ListItems.Add , , 111
ListView1.ListItems(ListView1.ListItems.Count).SubItems(1) = "apple"
ListView1.ListItems(ListView1.ListItems.Count).SubItems(2) = "100"
ListView1.ListItems.Add , , 222
ListView1.ListItems(ListView1.ListItems.Count).SubItems(1) = "mango"
ListView1.ListItems(ListView1.ListItems.Count).SubItems(2) = "200"

End Sub

than you very much the code you gave is working.but i have no any idea about below code part.

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

if can please explain me.
if can please tell me how can i upgrade my 5.0(sp2) version to 6.0 version.if can give me a link

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.