Your code works as expected (after the typo correction) and does indeed call _CheckedChanged.
Yes it was a typo, but all is not well with it. I tried to create a small project to demo, but the small project works fine. But here is what I have also found with my much larger project:
- The error is only thrown in debug mode.
- The _CheckedChanged sub appears to be called twice even though the SetChecked method is only called once.
- It is only thrown if the _CheckedChange exists, and occurs even if there is no code in the _CheckedChanged sub. Remove (or comment out) the _CheckedChange sub and the error does not occur.
- It doesn't make any difference whether the setting is to True or False
- A "CheckAll" method just before the SetChecked method runs without throwing any errors.
Here is the code as written. I have simplified the offending statement for clarity:
Sub Setup_PGInitialData
Log($"Setup_PGInitialData"$)
' … some Code not related to ccbx errors
' Clear the existing selections
'' This does NOT throw any errors:
ccbxMusicType.CheckAll(False)
Log("Setting ccbx selection")
' Add the new one
'' This throws errors in debug mode
ccbxMusicType.SetChecked(9, True)
' … Other code not related to the ccbx error:
Log("Ending sub")
End Sub
' This Is where the errors are thrown
' If this is commented out, no errors are thrown
Sub ccbxMusicType_CheckedChanged
Log("CheckedChanged")
End Sub
When the code is run, in Debug mode I then get this (which I am led to believe I can ignore?):
Unexpected event (missing RaiseSynchronousEvents): ccbxmusictype_checkedchanged
with a string of other related error logs.
But THEN the logs show this:
Ending sub
CheckedChanged
CheckedChanged
Error occurred on line: 531 (MB_Add)
java.lang.IllegalArgumentException
at jdk.internal.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:373)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:181)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1018)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Error occurred on line: 531 (MB_Add)
java.lang.NullPointerException
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:373)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:181)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at flm.b4j.tableviewextended.CellFactory$MyTableCell.updateItem(CellFactory.java:56)
at javafx.controls/javafx.scene.control.TableCell.updateItem(TableCell.java:665)
at javafx.controls/javafx.scene.control.TableCell.indexChanged(TableCell.java:469)
at javafx.controls/javafx.scene.control.IndexedCell.updateIndex(IndexedCell.java:120)
at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.updateCells(TableRowSkinBase.java:539)
at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.<init>(TableRowSkinBase.java:159)
at javafx.controls/javafx.scene.control.skin.TableRowSkin.<init>(TableRowSkin.java:89)
at javafx.controls/javafx.scene.control.TableRow.createDefaultSkin(TableRow.java:213)
at javafx.controls/javafx.scene.control.Control.doProcessCSS(Control.java:897)
and many more lines that appear to have no bearing on this.
at which point the program stops.
Interesting that the "Error occurred on line: 531" appears twice.
Does this provide any clues? The statement on Line 531 is End Sub (from the _CheckedChanged sub).