Listbox checkmark weird behavior for me

Desktop
I am having a weird checkmark problem.
I put the checkmark in the cell
me.CellCheckBoxValueAt( row, column ) = True

I click on the cell with the mark (do stuff with code) and it disappears with the same code as above.

I have also used this code and it still disappears
me.CellCheckBoxStateAt( row, column ) = Checkbox.VisualStates.Checked

If I didn’t put that line of code in there, the checkmark would still be there, but I need that code in there.
Am I missing something?

Where are you putting that code?
If it’s inside some kind of mouse click events, and you don’t return true, your code will check the box and Xojo, as part of the following of the event, will act as normal (toggle the check, therefore unchecking it again). Use “Return true” to tell the framework to not do its normal task.

If not in such an event, it’d be curious no one already noticed such a bug.

if you make a cell to be of type Checkbox
and set the tick when the window opens.
Then you dont need any code to set it after that point.
the user can click the cell and it will tick or untick like a normal checkbox.

When the window closes, ask the cell for its value and store it or use it.

In older code i have used

//make the cell a checkbox
mylist.CellType(therow,3) = listbox.TypeCheckbox

//set it once
mylist.cellstate(therow,3) = Checkbox.CheckedStates.Checked



//test condition later

if mylist.cellstate(therow,3)= Checkbox.CheckedStates.Checked then

Thank you

That solved the problem. Is this normal or should I prepare (create a micro project) to maybe file a bug report.

Sorry I didn’t realize I’d left out some details like CellCllick until the edit time had passed.

The code is CellClick and here’s the reason I needed the code. There is the native path for a sound file in the cell and if there is text it should be checked. By clicking on the chcck mark one has the options of playing the xound file or changing the folder item, including changing to no folderitem. So If I am changing it, the code has to recheck whether it needs to be checked or unchecked.

That’s expected and fairly logical.

Steps to understand (I hope):
1: add the CellClick event to a listbox and leave the event empty. Run the project. You’ll be able to click the checkbox which wll act normally. Why? Because Xojo handles it for you (like if you haven’t added the event at all). Just adding an event doesn’t mean you override Xojo’s behaviour.
2: even filling the event doesn’t change step 1. Add, say, a MessageBox to the event (and nothing more) and you’ll still be able to check the box normally in the app.
3: if you toggle the checkbox by code in the CellClick event, Xojo will behave as usual (why would it change magically?) and toggle the checkbox (from your code) then toggle it itself (from the framework, like with an empty event). This toggles the box twice, thus reset it back.
4: there are several events having a return value of type boolean (MouseDown, KeyDown, CellClick, etc.). Those share the same concept: if you return nothing (like with an empty event) or return false (returning nothing is equivalent to returning the default value, false, here), the natural behaviour occurs (thus lets the framework do its work). And returning true is exactly for telling Xojo “Don’t do your own action(s) after this event finishes; I already did all I want”.

Is that more clear?