listview and checkbox

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

listview and checkbox

Post by sal21 »

i'm on vb 6.0

I need to permit to the user to check only a checkbox,"one by one", and not permit to use a multiselect checkbox, possible?

Similar oprtion button.

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: listview and checkbox

Post by HansV »

Create an event procedure for the ItemCheck event of the listview:

Code: Select all

Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
    Static LastChecked As ListItem
    If Item.Checked Then
        If Not LastChecked Is Nothing Then
            LastChecked.Checked = False
        End If
        Set LastChecked = Item
    End If
End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: listview and checkbox

Post by sal21 »

HansV wrote:Create an event procedure for the ItemCheck event of the listview:

Code: Select all

Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
    Static LastChecked As ListItem
    If Item.Checked Then
        If Not LastChecked Is Nothing Then
            LastChecked.Checked = False
        End If
        Set LastChecked = Item
    End If
End Sub
I have no words!!!!

Work perfect!
Tks bro