Jahanzaib Bokhari
Jahanzaib Bokhari

Reputation: 39

c# Loop through multiple bunifu checkboxes

I have a program which have multiple check boxes on a windows form. I am using Bunifu framework for the check boxes. I want to loop through all the check boxes. However, I can't seem to loop through with bunifu check boxes, it works with normal check boxes.

I have tried the following code. It works as intended with normal check boxes but not working for bunifu check boxes. The code doesn't think its a checkbox I believe.

foreach (Control ctrl in this.Controls)
            {
                if (ctrl is CheckBox)
                {
                    if(((CheckBox)ctrl).Checked == true)
                    {

                       //main code here

                    }
                }
            }

I want to be able to do same thing but with the bunifu check boxes. Is there something I am missing.

Thanks for your help.

Upvotes: 0

Views: 308

Answers (1)

Amos Chepchieng
Amos Chepchieng

Reputation: 116

Do something like but make sure you are using latest Bunifu Framework.

foreach (Bunifu.UI.WinForms.BunifuCheckBox ctrl in this.Controls)
            {
                if (ctrl is Bunifu.UI.WinForms.BunifuCheckBox)
                {
                    if(((Bunifu.UI.WinForms.BunifuCheckBox)ctrl).Checked == true)
                    {

                       //main code here

                    }
                }`enter code here`
            }

Upvotes: 0

Related Questions