Hallo,
mein Ziel ist es eine große Anzahl von PictureBox'en zur Laufzeit zu
erstellen.
Sie sollen fortlaufend z.B. PicBox_1 und Pic_Box_2 ...usw. ... heißen.
1 | PictureBox PicBox_1 = new PictureBox();
|
2 | PicBox_1.Size = new System.Drawing.Size(10, 10);
|
3 | PicBox_1.Location = new System.Drawing.Point(50, 50);
|
4 | ...
|
5 | Controls.Add(PicBox_1);
|
Diesen Code möchte ich nun etwa so umsetzen:
1 | for(int i=0;i<=100;i++)
|
2 | {
|
3 | PictureBox PicBox_[i] = new PictureBox();
|
4 | PicBox_[i].Size = new System.Drawing.Size(10, 10);
|
5 | ...
|
6 | Controls.Add(PicBox_[i]);
|
7 | }
|
Das geht aber nicht!
Also suche ich nach so einer Lösung:
1 | String[] XXX = new String[99];
|
2 |
|
3 | for(int i=0;i<=100;i++)
|
4 | {
|
5 | PictureBox Convert.StringToVariablename( XXX[i] ) = new PictureBox();
|
6 | ...
|
7 | }
|
Kann man aus einem String einen Variablennamen erzeugen ???