I would PM but you dont accept them for some reason.

Would you be able to help me with the code you gave me

  buttons.Add(button2);       buttons.Add(button3);  //e.t.c

I'm trying to get the code to work with Devcomponet buttons, but every code I can think of doesnt work.

Edited 6 Years Ago by trippinz: n/a

I provided an example working with a generic list of buttons, the "Button" being a common winform control. If you're using something other than the regular button, obviously List<Button> will not work. Make it List<WhateverTheTypeYouNeed> instead.

Search google and read up on generic collections in .NET and C#. But the quick takeaway is that you can use them for whatever collection you need, be it a collection of integers, doubles, strings, controls, defined types, anonymous types, etc. List<T>, where T is whatever you throw at it.

I provided an example working with a generic list of buttons, the "Button" being a common winform control. If you're using something other than the regular button, obviously List<Button> will not work. Make it List<WhateverTheTypeYouNeed> instead.

Search google and read up on generic collections in .NET and C#. But the quick takeaway is that you can use them for whatever collection you need, be it a collection of integers, doubles, strings, controls, defined types, anonymous types, etc. List<T>, where T is whatever you throw at it.

I see. Ill try sommat

When I try to use

buttons.Add(buttonX1);

the whole line comes up with a error

am i doing this right ?

Edited 6 Years Ago by trippinz: n/a

buttons.Add(buttonX1);
buttons.Add(buttonX2);
buttons.Add(buttonX3);
buttons.Add(buttonX4);
buttons.Add(buttonX5);
buttons.Add(buttonX6);
buttons.Add(buttonX7);
buttons.Add(buttonX8);
buttons.Add(buttonX9);
buttons.Add(buttonX10);
buttons.Add(buttonX11);
buttons.Add(buttonX12);
buttons.Add(buttonX13);
buttons.Add(buttonX14);
buttons.Add(buttonX15);
buttons.Add(buttonX16);
buttons.Add(buttonX17);
buttons.Add(buttonX18);
buttons.Add(buttonX19);
buttons.Add(buttonX20);
buttons.Add(buttonX21);
buttons.Add(buttonX22);
buttons.Add(buttonX23);
buttons.Add(buttonX24);
buttons.Add(buttonX25);
buttons.Add(buttonX26);
buttons.Add(buttonX27);
buttons.Add(buttonX28);
buttons.Add(buttonX29);
buttons.Add(buttonX30);
buttons.Add(buttonX31);
buttons.Add(buttonX32);
buttons.Add(buttonX33);
buttons.Add(buttonX34);
buttons.Add(buttonX35);
buttons.Add(buttonX36);
buttons.Add(buttonX37);
buttons.Add(buttonX38);
buttons.Add(buttonX39);
buttons.Add(buttonX40);
buttons.Add(buttonX41);
buttons.Add(buttonX42);
buttons.Add(buttonX43);
buttons.Add(buttonX44);
buttons.Add(buttonX45);
buttons.Add(buttonX46);
buttons.Add(buttonX47);
buttons.Add(buttonX48);
buttons.Add(buttonX49);
buttons.Add(buttonX50);
buttons.Add(buttonX51);
buttons.Add(buttonX52);
buttons.Add(buttonX53);
buttons.Add(buttonX54);
buttons.Add(buttonX55);
buttons.Add(buttonX56);
buttons.Add(buttonX57);
buttons.Add(buttonX58);
buttons.Add(buttonX59);
buttons.Add(buttonX60);
buttons.Add(buttonX61);
buttons.Add(buttonX62);
buttons.Add(buttonX63);
buttons.Add(buttonX64);
buttons.Add(buttonX65);
buttons.Add(buttonX66);
buttons.Add(buttonX67);
buttons.Add(buttonX68);
buttons.Add(buttonX69);
buttons.Add(buttonX70);
buttons.Add(buttonX71);
buttons.Add(buttonX72);
buttons.Add(buttonX73);
buttons.Add(buttonX74);
buttons.Add(buttonX75);
buttons.Add(buttonX76);
buttons.Add(buttonX77);
buttons.Add(buttonX78);
buttons.Add(buttonX79);
buttons.Add(buttonX80);
buttons.Add(buttonX81);
buttons.Add(buttonX82);
buttons.Add(buttonX83);
buttons.Add(buttonX84);
buttons.Add(buttonX85);
buttons.Add(buttonX86);
buttons.Add(buttonX87);
buttons.Add(buttonX88);
buttons.Add(buttonX89);
buttons.Add(buttonX90);
buttons.Add(buttonX91);
buttons.Add(buttonX92);
buttons.Add(buttonX93);
buttons.Add(buttonX94);
buttons.Add(buttonX95);
buttons.Add(buttonX96);
buttons.Add(buttonX97);
buttons.Add(buttonX98);
buttons.Add(buttonX99);
buttons.Add(buttonX100);
buttons.Add(buttonX101);
buttons.Add(buttonX102);
buttons.Add(buttonX103);
buttons.Add(buttonX104);
buttons.Add(buttonX105);
buttons.Add(buttonX106);
buttons.Add(buttonX107);
buttons.Add(buttonX108);
buttons.Add(buttonX109);
buttons.Add(buttonX110);
buttons.Add(buttonX111);
buttons.Add(buttonX112);
buttons.Add(buttonX113);
buttons.Add(buttonX114);
buttons.Add(buttonX115);
buttons.Add(buttonX116);
buttons.Add(buttonX117);
buttons.Add(buttonX118);
buttons.Add(buttonX119);
buttons.Add(buttonX120);
buttons.Add(buttonX121);
buttons.Add(buttonX122);
buttons.Add(buttonX123);
buttons.Add(buttonX124);
buttons.Add(buttonX125);
buttons.Add(buttonX126);
buttons.Add(buttonX127);
buttons.Add(buttonX128);
buttons.Add(buttonX129);
buttons.Add(buttonX130);
buttons.Add(buttonX131);
buttons.Add(buttonX132);
buttons.Add(buttonX133);
buttons.Add(buttonX134);
buttons.Add(buttonX135);
buttons.Add(buttonX136);
buttons.Add(buttonX137);
buttons.Add(buttonX138);
buttons.Add(buttonX139);
buttons.Add(buttonX140);
buttons.Add(buttonX141);
buttons.Add(buttonX142);
buttons.Add(buttonX143);
buttons.Add(buttonX144);
buttons.Add(buttonX145);
buttons.Add(buttonX146);
buttons.Add(buttonX147);
buttons.Add(buttonX148);
buttons.Add(buttonX149);
buttons.Add(buttonX150);
buttons.Add(buttonX151);
buttons.Add(buttonX152);
buttons.Add(buttonX153);
buttons.Add(buttonX154);
buttons.Add(buttonX155);
buttons.Add(buttonX156);
buttons.Add(buttonX157);
buttons.Add(buttonX158);
buttons.Add(buttonX159);
buttons.Add(buttonX160);
buttons.Add(buttonX161);
buttons.Add(buttonX162);
buttons.Add(buttonX163);
buttons.Add(buttonX164);
buttons.Add(buttonX165);
buttons.Add(buttonX166);
buttons.Add(buttonX167);
buttons.Add(buttonX168);
buttons.Add(buttonX169);
buttons.Add(buttonX170);

That's not what I meant. How are you declaring the list? And if you're going to have that many controls to throw at it, it's probably better to be less verbose about getting your controls into it. You can query the Controls collection of the Form (or whatever the parent object happens to be) to get the list instead.

Edit: OK, you fixed it. Good.

Edited 6 Years Ago by apegram: n/a

That's not what I meant. How are you declaring the list? And if you're going to have that many controls to throw at it, it's probably better to be less verbose about getting your controls into it. You can query the Controls collection of the Form (or whatever the parent object happens to be) to get the list instead.

Edit: OK, you fixed it. Good.

EDIT: He didn't fix it, I mean I didnt fix it. Everyone of those lines has a error. 291 errors. What is the thing I need to look up?

Edited 6 Years Ago by GAME: n/a

Comments
Be patient!

EDIT: He didn't fix it, I mean I didnt fix it. Everyone of those lines has a error. 291 errors. What is the thing I need to look up?

im working with him =D

This article has been dead for over six months. Start a new discussion instead.