Checkbox Array?

Smee

Well-Known Member
Licensed User
Longtime User
I reguarly use buttons with one routine and depending on the button pressed perform an action

for eg
B4X:
Sub btnAction_Click
   Dim btn As Button ' use to find which button sent us here
   btn = Sender ' this sent us here
   BtnVal=btn.Tag
   
   Select BtnVal
   Case 0
           Case 1
           .........
           .........
           .........
           End Select

Is there a way to do similar with checkboxes?

I want to test if a checkbox is checked or not and to be able to programatically select or unselect individual boxes but all within the one code module.

Thanks for some great software Erel.
 

klaus

Expert
Licensed User
Longtime User
It's exactly the same, just replace Button by CheckBox:
B4X:
Sub cbxSelection_CheckedChange(Checked As Boolean)
    Dim cbx As CheckBox ' used to find which CheckBox raised the event
    cbx = Sender 
    
    Select cbx.Tag
    Case 0
    Case 1
    .........
    .........
    .........
    End Select
This valid for all types of views.

Best regards.
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Thankyou Klaus,

But how do i programatically select or unselect individual boxes?

joe
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
To do this you need to define an Array of the CheckBoxes.
Then you can programaticaly get or set the checked property.
CheckBoxes(0).Checked = False

Have a look at chapter 10.3.3 in the Beginner's Guide.
The example shown is with Buttons but the same can be done with CheckBoxes.

Best regards.
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Thanks Klaus,

I Did that but when i select the checkbox with the code statement

B4X:
rbDays(0).Checked=True

The checkbox status changes but the CheckedChange event does not fire

if i press the checkbox manually it does fire

:BangHead:
 
Upvote 0

alexposta2

Member
Licensed User
Longtime User
Hi Klaus, I've tried with toggle button, but the event checked seems to raised also from code.

It's possible?

thank you
Alessio
 
Upvote 0
Top