Example doc desktopCheckBox.visualstate not working

i trying to figure out how how to test state of checkBox
reading the doc didn’t help, as example doesn’t work

funny thing i bumped into this so while ago, i forgot how this works :upside_down_face:
i might trying search my own code, but doc should be fixed

There is an error in the documentation example: you should try this

Case DesktopCheckBox.VisualStates.Unchecked
  
1 Like

ah yes thanks i thought i tried that before !

found out that this works

if checkBox1.VisualState = desktopCheckBox.VisualStates.Checked then

a bit long but well

Try

Select Case Int64(Checkbox.VisualState)
Case Int64(Checkbox.VisualStates.Unchecked)

End Select

Or

Select Case CheckBox1.VisualState
Case DesktopCheckbox.VisualStates.Unchecked

End Select
1 Like

ok thanks, actually i was looking for a single line if condition shorter than this

if checkBox1.VisualState = desktopCheckBox.VisualStates.Checked then

something like

if checkBox1.VisualState = 1 then

replace with enum number or something
tbh i don’t know how to manage enum that much

Why? `that just makes your code less readable and less maintainable. Bad idea.

well sorry but i prefer to read this

than this

it hurts my brain,i have to decode the string, waste of brain cpu
a checkbox has only 3 state
0
1
2
easier to understand imo

And what does 1 mean?

2 Likes

The documentation should being using: DesktopCheckBox rather than CheckBox for the Case conditions. I’ve just updated this example code in the docs so it should be up to date now.

2 Likes