tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
2
ZUGRIFFE
364
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    bimiko bimiko ist offline Grünschnabel
    Registriert seit
    Oct 2010
    Beiträge
    3
    Hallo, bin am verzweifeln. Suche seit 2 tagen eine möglichkeit textboxen dynamisch zu überprüfen, inhalt löschen, inhalt ersetzen.

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    foreach (string i in liste)
                {
                    if (i.Contains("="))
                    {
                        Tabelle = i.Split('=');
                        if (textBox1.Text == Tabelle[0]) textBox20.Text = Tabelle[1];
                        if (textBox2.Text == Tabelle[0]) textBox21.Text = Tabelle[1];
                        if (textBox3.Text == Tabelle[0]) textBox22.Text = Tabelle[1];
                        if (textBox4.Text == Tabelle[0]) textBox23.Text = Tabelle[1];
                        if (textBox5.Text == Tabelle[0]) textBox24.Text = Tabelle[1];
                        if (textBox6.Text == Tabelle[0]) textBox25.Text = Tabelle[1];
                        if (textBox7.Text == Tabelle[0]) textBox26.Text = Tabelle[1];
                        if (textBox8.Text == Tabelle[0]) textBox27.Text = Tabelle[1];
                        if (textBox9.Text == Tabelle[0]) textBox28.Text = Tabelle[1];
                        if (textBox10.Text == Tabelle[0]) textBox29.Text = Tabelle[1];
                        if (textBox11.Text == Tabelle[0]) textBox30.Text = Tabelle[1];
                        if (textBox12.Text == Tabelle[0]) textBox31.Text = Tabelle[1];
                        if (textBox13.Text == Tabelle[0]) textBox32.Text = Tabelle[1];
                        if (textBox14.Text == Tabelle[0]) textBox33.Text = Tabelle[1];
                        if (textBox15.Text == Tabelle[0]) textBox34.Text = Tabelle[1];
                        if (textBox16.Text == Tabelle[0]) textBox35.Text = Tabelle[1];
                        if (textBox17.Text == Tabelle[0]) textBox36.Text = Tabelle[1];
                        if (textBox18.Text == Tabelle[0]) textBox37.Text = Tabelle[1];
                        if (textBox19.Text == Tabelle[0]) textBox38.Text = Tabelle[1];

    mein code ist voll mit solchen riesigen blöcken von textBox aufzählungen.
    habe 38 textboxen. muss noch um die 200 textboxen hinzufügen.
    wie ich textboxen dynamisch hinzufüge weiß ich.

    Schreibe ein Formular-Programm und mir ist nichts besseres eingefallen.

    gibt es sowas wie:
    Code :
    1
    2
    3
    4
    5
    6
    
    for (int i=1;i<=200;i++)
          {
             (variable)"ArrayList"[i].Clear();
              oder
              (variable)textBox[i].Text = "Hallo Welt";
           }
     

  2. #2
    Masterclavat Masterclavat ist offline Mitglied Brokat
    Registriert seit
    Oct 2007
    Beiträge
    325
    Die Klasse "System.Windows.Forms.Form" hat eine Eigenschaft "Controls", welche eine Auslistung aller Controls auf der Form ist.

    Etwa so:

    Code csharp:
    1
    2
    3
    4
    5
    6
    7
    8
    
    foreach (Control control in this.Controls)
    {
       TextBox textBox = control as TextBox;
       if (textBox != null)
       {
          // control ist eine TextBox
       }
    }
    Geändert von Masterclavat (09.10.10 um 13:19 Uhr)
     

  3. #3
    bimiko bimiko ist offline Grünschnabel
    Registriert seit
    Oct 2010
    Beiträge
    3
    Vielen vielen Dank.
    Hab mich schon kaputtgesucht.
    Naja, ist immer so wenn man das Schlagwort (hier control) nicht kennt, dann sucht man ja nur durch Beschreibungen und findet meistens nichts gescheites.

    Danke nochmal.
     

Ähnliche Themen

  1. Dynamische Variablen in VBA
    Von NeMeSiS1987 im Forum Visual Basic 6.0
    Antworten: 1
    Letzter Beitrag: 27.06.08, 13:55
  2. Dynamische Variablen
    Von MaxMara im Forum PHP
    Antworten: 4
    Letzter Beitrag: 06.06.06, 15:55
  3. Dynamische Variablen
    Von con-f-use im Forum Javascript & Ajax
    Antworten: 2
    Letzter Beitrag: 02.11.04, 12:20
  4. Dynamische Variablen/Formularelemente
    Von Chino im Forum Javascript & Ajax
    Antworten: 4
    Letzter Beitrag: 18.06.03, 20:26
  5. dynamische variablen
    Von pong im Forum Flash Plattform
    Antworten: 4
    Letzter Beitrag: 23.05.02, 19:00

Stichworte