Make a checkbox ArrayList

1

I have managed to put a checkbox array on the Form1.Designer.cs such that:

this.caja = new System.Windows.Forms.CheckBox[] {checkBox1 , checkBox2, checkBox3, checkBox4, checkBox5, checkBox6,
         checkBox7 ,checkBox8 ,checkBox9 ,checkBox10 ,checkBox11 ,checkBox12 ,checkBox13 ,checkBox14 ,checkBox15 ,checkBox16};

I wanted to know if it can be put with ArrayList:
I put it like that and I get an error:

this.caja = new System.Windows.Forms.CheckBox ArrayList caja = new ArrayList() { };
    
asked by Armandix23 28.11.2017 в 10:23
source

1 answer

3

Several things. First, do not touch the Designer.cs , since it is self-generated and can give you problems, you can do the same in the code of your form.

Second, do not use ArrayList , it is a class that is obsolete and has been replaced by the generic class List .

In the case that you expose, using List your code would be the following:

List<CheckBox> listaCb = new List<CheckBox>() { checkBox1 , checkBox2... };

On the other hand, if this.caja is of type CheckBox[] , you must also modify its definition to be List<CheckBox> :

List<CheckBox> caja;
    
answered by 28.11.2017 / 10:30
source