Hi all,
I have 6 textboxes, each of which has a number at the end of the name (1-6).I also have an array (numbers) holding 6 values.
I'm currently using the code below to place the array value in the corresponding textbox :-
As I'm new to c#, I was wondering if there was a more elegant way of completing this task. I'd be glad of any help.
Thanks in advance.
I have 6 textboxes, each of which has a number at the end of the name (1-6).I also have an array (numbers) holding 6 values.
I'm currently using the code below to place the array value in the corresponding textbox :-
foreach (Control ctl in Controls)
{
var box = ctl as TextBox;
if (box != null)
{
if (box.Name.Contains((x + 1).ToString()))
{
box.Text = numbers[x].ToString();
box.Refresh();
}
}
}
As I'm new to c#, I was wondering if there was a more elegant way of completing this task. I'd be glad of any help.
Thanks in advance.