This project has moved. For the latest updates, please go here.

C# forms: generate controls at runtime

Oct 23, 2010 at 7:14 PM

Hi, me again with some C# troubles. The last time I programed a gui was with VB 6.0. There it was easy to drop one control and then copy past it. The result is a control which can be accessed as an array like label[0] label[1] and so on.

Similar to this I want to have a C# form with multiple controls which are looking the same but the number can be defined on the first form load. Is this possible?

First I thought of using this flowLayoutPanel but it seems that the added controls have to be defined as a member of the class. When I change them to an array it isn't working any more. Do I really need to make for every control an own class member? What sense makes this flowLayoutPanel if I can't say, for example: show this control 10 times? It's just for placement?

Hope we have some gui gurus here...