displaying data in more than one textbox C#
-
i have no idea what to name this to. but anyway, i hope i can get some help i have a while loop which shall go through a few textboxes the textboxes are named textBox1, textBox2 my code is following int count = 0; while(blah) { count++; textBox???.Text = "blah"; } I want to dynamically set the different textboxes with different values, the while loop should through textbox1, textbox2 and so on. how do i make that? i hope i explained myself good enough
-
i have no idea what to name this to. but anyway, i hope i can get some help i have a while loop which shall go through a few textboxes the textboxes are named textBox1, textBox2 my code is following int count = 0; while(blah) { count++; textBox???.Text = "blah"; } I want to dynamically set the different textboxes with different values, the while loop should through textbox1, textbox2 and so on. how do i make that? i hope i explained myself good enough
Why You are using this while loop....... You can add all the textboxes to a panel or groupbox then you can use the foreach method like foreach(TextBox txtbox in panelTextBoxes.Controls) { txtbox.Text = " "; }
My small attempt...
-
i have no idea what to name this to. but anyway, i hope i can get some help i have a while loop which shall go through a few textboxes the textboxes are named textBox1, textBox2 my code is following int count = 0; while(blah) { count++; textBox???.Text = "blah"; } I want to dynamically set the different textboxes with different values, the while loop should through textbox1, textbox2 and so on. how do i make that? i hope i explained myself good enough
Place each of your textboxes in an Array and set them that way.
TextBox [] tbArray = new TextBox[] { this.textBox1, this.textBox2 }; int count = 0; while(blah) { tbArray[count].Text = "Blah"; count++; }
-
Place each of your textboxes in an Array and set them that way.
TextBox [] tbArray = new TextBox[] { this.textBox1, this.textBox2 }; int count = 0; while(blah) { tbArray[count].Text = "Blah"; count++; }