U
U
Username2015-09-26 16:19:11
Programming
Username, 2015-09-26 16:19:11

How to refer to the i-th element of the TextBox?

In total there are 10 textBoxes named textBox1, textBox2,..., textBox10, how to access each by looping from 1 to 10 and put each value into an int array? Kind of like textBoxes are an object, each one can be referred to as the i-th element. How can this be implemented in c#?
25578100f7be47f18f363004e6c312bc.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tsiren Naimanov, 2015-09-26
@ImmortalCAT

create an array of textboxes
and iterate their
current fill in initializecomponent();

E
Egor S, 2015-09-26
@mortyyyy

foreach (Control c  in this.Controls)
{
     if (c is TextBox)
     {
         ...
     }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question