This piece of code is in the Pressed event of a DesktopButton. The text in cell (0,0) is not editable. The state of the CheckBox (cell (0,1) can be changed. How to avoid this?
Thatās the whole point. Why would you put a checkbox in a listbox if you didnāt want it to be clickable? If you donāt want it clickable, draw an icon into the cell.
The ListBox shows a list of members. One column in the list indicates the payment status (paid = checked/unpaid = unchecked. it doesnāt make sense to be able to change the status of a checkbox cell in the ListBox.
Emile, yes of course I can look for another solution to show the status (e.g. True/False, 1/0, a green/red imageā¦). There are so many solutions to solve this problem. My intention was to bring this issue to attention.I think this is still a mistake.
I think itās a valid use case: checkbox as read-only display element. Drawing it into the cell would be elegant, but Beatrixā workaround seems fine and simple.
I agree with the other Tim. An enabled Checkbox indicates to the user itās an input control. Thatās why in Lifeboat, the āIn Useā column is a UTF-8 checkmark. I think this communicates the boolean state while also being read only in a clear way.
Tim, I donāt agree with your remark. Why do I misuse the CheckBox?
A CheckBox can be used to input/display two-state values. In my case: āPaidā and āUnpaidā;
The Normal/Default CellType of a DesktopListBox is not editable. There is no remark in the documentation that a CheckBox cell changes the Cell type to āEditableā. Only TextField and TextArea types are defined āEditableā.
A traditional DesktopCheckBox control can be āEnabledā Or āDisabledā. Why is this not possible for a CheckBox cell in a ListBox?
So, for me this problem is either a minor bug or is a lack in the documentation where a CheckBox cell must be documented as editable.
A checkbox is specifically used to input Boolean / two-state values. When it is enabled the control indicates to the user they can change the value. The Checkbox isnāt clearly read-only until disabled.
Unfortunately, DesktopListbox cannot disable the Checkbox column type so you will need to file a feature request if you wish for the ability.
I would suggest displaying a text checkmark the way I do until youāre able to show read-only checkboxes. The UTF-8 checkmark solution also has the benefit of being cross platform with no extra work
I agree Tim, there are many solutions to solve this problem: I can use True/False, OK/NOK, two different images, two colors (e.g. green is paid, red is unpaidā¦), etc. This was the first time I tried to use a CheckBox in a ListBox and I was very surprised that this CheckBox cell was editable. From now on I will use the simple UTF-8 checkmark.
@Beatrix_Willius The NOT operator cannot be used in this case (A CheckBox can have 3 states). This is the code you have to use in the CellAction event:
If CellCheckBoxStateAt(row, column) = DesktopCheckBox.VisualStates.Checked Then
CellCheckBoxStateAt(row,column) = DesktopCheckBox.VisualStates.UnChecked
Else
CellCheckBoxStateAt(row,column) = DesktopCheckBox.VisualStates.Checked
End If```
If you actually want to allow the user to choose between the three states, CellCheckBoxStateAt is indeed the correct method.
Otherwise, with only two states allowed, youād better use CellCheckBoxValueAt instead, which simplifies your code as you can use the ānotā operator.