Hi,
I have a listbox with two columns. Column 0 holds checkboxes. When the user clicks on the check box in the first row, all other rows should be unselected. When the user clicks on any row other than 0, it should uncheck row 0.
I put the following code in the CellAction
event and it works fine.
Sub CellAction(row As Integer, column As Integer)
if row = 0 then
if me.CellCheck(row,0) then
For i As Integer = 0 to me.ListCount -1
If i <> row then
me.CellCheck(i, column) = False
End If
Next i
end if
else
me.CellCheck(0, 0) = False
end if
End Sub
However, I would like it so that the user can click on the row itself to toggle the checkbox. So I added this to the Change
event:
Sub Change()
me.CellCheck(me.listindex, 0) = not me.CellCheck(me.listindex, 0)
End Sub
This works, but if you click too fast the toggle doesn’t happen. I even tried invalidatecell
after this code, with the same results. Also it doesn’t fire the CellAction
event. Any ideas?
Thank you