CellPressed question

Hello,

i just want to count all rows with checked checkbox, so my CellPressed Event looks like:

if column=0 then
  list.RefreshCell(row,-1)
  
  scannedProducts=0
  
  for i as integer= 0 to me.LastRowIndex
    
    if me.CellCheckBoxStateAt(i,0)=DesktopCheckBox.VisualStates.checked then
      scannedProducts=scannedProducts+1
    end if
    
  next
  sProducts.text=scannedProducts.ToString
  
end if

but its not working as expected, it only updates the value if clicked besides the checkbox…

its working when put into PaintCellBackground…

Why?
Marco

The checkbox state isn’t updated until after the CellPressed event so that count wont include the currently changing checkbox.

Ok i understand. But in which event do i have to put that Code to immediately update the count when the checkbox is clicked? Cellbackgroundpaint does work but does not seem to be the right place.

Marco

CellAction fires after the checkbox change so you can use that, just make sure you check what column was clicked if you have other editable columns in the listbox as this is the same event that fires when a cell edit is complete.