Store checked/filled objects in a string for each panel

48 views Asked by At

My program generates dynamic a specific amount of panels with checkboxes / textboxes. In next step, I want store them in a csv file with ";" as Delimiter. But firstly, i have to create the string for each panel. I tested the following with the checkbox:

foreach (object cb in ((CheckBox)sender).Parent.Controls)
{
    if (cb is CheckBox)
    {
        if (((CheckBox)cb).Checked)
        { str1 += ((CheckBox)cb).Text + "1;"; }

        if (!((CheckBox)cb).Checked)
        { str1 += ((CheckBox)cb).Text + "0;"; }
    }
}

I implemented this already in the CheckBox_CheckedChanged Listener - str1 have the right formating, but when I click on another panel the string gets overwritten.

How can I store them seperatly for each panel?

In the next step, I want the foreach loop outside of the CheckedChanged Listener, but then I have no sender, to the get parent information.

enter image description here

0

There are 0 answers