reset all checkbox

2 Answers 321 Views
CheckedListBox GroupBox TextBox
ebrahim
Top achievements
Rank 1
Iron
Iron
ebrahim asked on 22 Nov 2021, 04:07 PM

hi

Why do I want to uncheck all the form checkboxes, but the regular checkbox is done ?!

 

 

my code is

void ClearForm(GroupBox control)
        {
               
            
                foreach (Control chexkBox in control.Controls)
                {
                    if (chexkBox is CheckBox)
                    {
                        ((CheckBox)chexkBox).Checked = false;

                    }


                }

                foreach (Control textBox in control.Controls)
                {
                if (textBox.GetType() == typeof(TextBox))
                    {
                        ((TextBox)textBox).Text = "no";

                    }

                }
            

           


        }
ebrahim
Top achievements
Rank 1
Iron
Iron
commented on 24 Nov 2021, 04:56 PM

hi mr dinko

picture attach

The above telerik checkboxes do not remove their check, but the Visual Basic checkbox itself is removed.

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 24 Nov 2021, 12:16 PM

Hello ebrahim,

Thank you for the provided code snippet.

I am not exactly sure that I have fully understood your approach. May I ask you to share your structure so that I can replicate it on my side? You can also elaborate more on what is not working.

I am looking forward to your reply.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Dinko | Tech Support Engineer
Telerik team
answered on 25 Nov 2021, 11:38 AM

Hi ebrahim,

Thank you for the provided image.

To uncheck the items inside the RadCheckedListBox, you need to use the Items collection property of the control. Basically, the control derives from RadListView and you can directly get the checkboxes inside the ListViewDataItem. However, the ListViewDataItem exposes the CheckState enumeration property which I think is what you are looking for. You can check the following code snippet which will better demonstrate what I have in mind.

private void radButton1_Click(object sender, EventArgs e)
{
    foreach (Control element in this.Controls)
    {
        if (element is RadCheckedListBox)
        {
            foreach (var item in (element as RadCheckedListBox).Items)
            {
                if (item.CheckState == Telerik.WinControls.Enumerations.ToggleState.On)
                {
                    item.CheckState = Telerik.WinControls.Enumerations.ToggleState.Off;
                }
                else
                {
                    item.CheckState = Telerik.WinControls.Enumerations.ToggleState.On;
                }                        
            }
        }
    }
}

Give this approach a try and let me know how it goes.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ebrahim
Top achievements
Rank 1
Iron
Iron
commented on 25 Nov 2021, 11:43 AM

thanks mr dinko
Tags
CheckedListBox GroupBox TextBox
Asked by
ebrahim
Top achievements
Rank 1
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or