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.
listview and checkbox
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: listview and checkbox
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
Hans
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
Re: listview and checkbox
I have no words!!!!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
Work perfect!
Tks bro
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
Re: listview and checkbox
HI BRO, sorry if i replay on old post.HansV wrote: ↑22 Mar 2020, 16:39Create 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
actually i use this code to check un check a checkbox in msflexgrid:
Code: Select all
Private Sub MSFlexGrid1_Click()
With MSFlexGrid1
If .Col = 0 And .Row >= 1 Then
If .CellPicture = picChecked Then
Set .CellPicture = picUnchecked
Else
Set .CellPicture = picChecked
End If
End If
End With
End Sub
In effect i need to maintain in live the last checked cell.
-
- Administrator
- Posts: 79287
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: listview and checkbox
I cannot test - does this work?
There may be better ways...
Code: Select all
Private Sub MSFlexGrid1_Click()
Static OldRow As Long, OldCol As Long
Static NewRow As Long, NewCol As Long
With MSFlexGrid1
NewRow = .Row
NewCol = .Col
If NewCol = 0 And NewRow >= 1 Then
If Not .CellPicture = picChecked Then
Set .CellPicture = picChecked
If OldCol = 0 And OldRow >= 1 Then
.Row = OldRow
.Col = OldCol
Set .CellPicture = picUnchecked
.Row = NewRow
.Col = NewCol
End If
OldRow = NewRow
OldCol = NewCol
End If
End If
End With
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4470
- Joined: 26 Apr 2010, 17:36
Re: listview and checkbox
great! Work!HansV wrote: ↑08 Aug 2024, 10:32I cannot test - does this work?
There may be better ways...Code: Select all
Private Sub MSFlexGrid1_Click() Static OldRow As Long, OldCol As Long Static NewRow As Long, NewCol As Long With MSFlexGrid1 NewRow = .Row NewCol = .Col If NewCol = 0 And NewRow >= 1 Then If Not .CellPicture = picChecked Then Set .CellPicture = picChecked If OldCol = 0 And OldRow >= 1 Then .Row = OldRow .Col = OldCol Set .CellPicture = picUnchecked .Row = NewRow .Col = NewCol End If OldRow = NewRow OldCol = NewCol End If End If End With End Sub
Tks