Confirming if a checkbox has been selected

Hi All.

I’m getting closer to what I want my little mortgage payment calculator program will do, but I’m having an issue determining the state of a checkbox in a listbox. Essentially, after you get your payment amortization, you should be able to click a checkbox to double up payments. But I can’t get that to happen.

Here is my checkbox code:

if mainWindow.ListBox1.CellCheckBoxValueAt(selectedRow, selectedColumn) = mainWindow.ListBox1.CellCheckBoxStateAt.Checked then
MessageBox “Checked”
else

end if

And here is my error:

mainWindow.Button1.Pressed, line 43
There is more than one method with this name but this does not match any of the available signatures.
if mainWindow.ListBox1.CellCheckBoxValueAt(selectedRow, selectedColumn) = mainWindow.ListBox1.CellCheckBoxStateAt.Checked then

I’ve searched the forum and the language reference but can’t seem to get it to work. Note that where the code says Messagebox “True” will hold other code in future.

Regards

Presumably this should be something like:

if  (mainWindow.ListBox1.CellCheckBoxStateAt(selectedRow, selectedColumn) = DesktopCheckbox.VisualStates.Checked)  then ...

Hi Tim.

No that doesn’t work. I get the errors:

mainWindow.Button1.Pressed, line 42
There is more than one method with this name but this does not match any of the available signatures.
if (mainWindow.ListBox1.CellCheckBoxStateAt(selectedRow, selectedColumn) = DesktopCheckbox.VisualStates.Checked) then

and

mainWindow.Button1.Pressed, line 42
Type mismatch error. Expected Int64, but got enum DesktopCheckBox.VisualStates
if (mainWindow.ListBox1.CellCheckBoxStateAt(selectedRow, selectedColumn) = DesktopCheckbox.VisualStates.Checked) then

I thought, from what I read, that the value should be a boolean, but tried that and no go, and even an integer, but no change.

Regards

Is your listbox a listbox or a desktoplistbox?

Hi Tim.

It is a desktoplistbox. That is I have a window with a listbox within it.

Regards

You can set it using a boolean:

mainWindow.ListBox1.CellCheckBoxValueAt(row, col) = True

Odd. Here’s line from my app:

mailboxes.CellCheckBoxStateAt(i,1) = DesktopCheckbox.VisualStates.Checked

mailboxes is a subclass of a subclass of DesktopListbox.

Here’s another way. This is another verbatim line from my app:

enabled = if  (me.CellCheckBoxValueAt(row,0)=False, 0, 1)

enabled is an integer. The above is a more compact way of writing:

if  (me.CellCheckBoxValueAt(row,0)=False)  then
  enabled = 0
else
  enabled = 1
end if

By the way, if your Listbox1 and Button1 are in the same window, then you don’t need to qualify code in one which refes to code in the other, with mainWindow. You can leave that off.

Thanks TIm.

I’ll give that a try. Just a quick question. I’m running xojo 2021r3.1. Is that what you are using? I’m liking it but when I am used to using Listbox for something and having to use DesktopListbox it is a little irritating… but I will learn!

Thank for your help…

Regards