In a listbox I have a column with checkboxes. Those checkboxes need to have 3 states. When loading data from the database everything works fine:
for currentRow as Integer = 0 to me.RowCount - 1
dim theIndex as Integer = getRowTagIndex(currentRow)
if theIndex = -1 then continue
if SelectionStatus(theIndex) = 1 then
me.CellCheckBoxStateAt(currentRow, 1) = CheckBox.VisualStates.Checked
elseif SelectionStatus(theIndex) = 2 then
me.CellCheckBoxStateAt(currentRow, 1) = CheckBox.VisualStates.Indeterminate
end if
next
But setting the CellCheckBoxState in the CellClick event like this does’t work:
'set cell state, checked -> indeterminate, indeterminate -> unchecked, unchecked -> checked
if me.CellCheckBoxStateAt(row, column) = CheckBox.VisualStates.Checked then
me.CellCheckBoxStateAt(row, column) = CheckBox.VisualStates.Indeterminate
ElseIf me.CellCheckBoxStateAt(row, column) = CheckBox.VisualStates.Indeterminate then
me.CellCheckBoxStateAt(row, column) = CheckBox.VisualStates.Unchecked
ElseIf me.CellCheckBoxStateAt(row, column) = CheckBox.VisualStates.Unchecked then
me.CellCheckBoxStateAt(row, column) = CheckBox.VisualStates.Checked
end if
If I have a checked checkbox then clicking on the checkbox removes the checkmark. Clicking on the checkbox again should show an indeterminate checkbox. Instead the checkbox is unchecked.
What am I doing wrong?