Autor Beitrag
ots_sharp
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mi 02.05.12 13:01 
Hallo,

in ein Array sollen ComboBoxen durchlaufen und weiter verarbeitet werden. Vielleicht kann das Problem auch ohne Array gelöst werden. Der Sinn liegt darin, dass bei Bedarf neue Boxen in die Auflistung zugefügt und die Eigenschaften, z.B. SelectedItem definiert werden. Die Eigenschaften der Boxen werden aus einer Textdatei gelesen und eingestellt.


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
private void DefineComboBox()
        {
         // Auflistung der ComboBoxen
         arrayBox (this.cB_Box1, this.cb_Box2,...)
         for each Box in arrayBox
            Get_ComboBox Box
         next Box
        }

private void Get_ComboBox(ComboBox objComboBox)
       {
         // irgendwas, z. B. objComboBox.SelectedItem = 1
       }
Gruß Stefan
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4805
Erhaltene Danke: 1061

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 02.05.12 13:23 
Hallo Stefan,

und was ist deine konkrete Frage dazu?
ots_sharp Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mi 02.05.12 13:29 
Wie definiere ich das array? Bisher habe ich nur Datentypen double, string, bool für Arrays gesehen. Keine Objekte.

arrayBox (this.cB_Box1, this.cb_Box2,...)
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4805
Erhaltene Danke: 1061

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 02.05.12 13:37 
Hallo Stefan,

eigentlich genauso:
ausblenden C#-Quelltext
1:
ComboBox[] comboBoxes = { this.cB_Box1, this.cb_Box2 /*, ... */ };					

Einen ausführlichen Artikel dazu gibt es unter myCSharp.de - Variablennamen zur Laufzeit zusammensetzen (konkret unter "Wie kann man - alle Warnungen im Sinn - die Designer Elemente in ein Array übertragen?").