Hi. I am having difficulty looping through texboxes. I do not want to use Controls. I have named my textboxes as:
textBoxBuy1, textBoxBuy2, textBoxBuy3, .....
There are many more textboxes in the form (with different names so that I can use the desired ones in a loop) but I do not want to refer to them while looping. I want to loop all the textboxes named textBoxBuy only. This is what I am doing:
for (int i = 1; i < 6; i++)
{
if ((TextBox)Contr ols["textBoxBuy " + i.ToString()].Text.Length != 0) {}
}
The error that I am getting is:
Error 1 Cannot convert type 'int' to 'System.Windows .Forms.TextBox'
Can someone please help me out with this?
Thanks
textBoxBuy1, textBoxBuy2, textBoxBuy3, .....
There are many more textboxes in the form (with different names so that I can use the desired ones in a loop) but I do not want to refer to them while looping. I want to loop all the textboxes named textBoxBuy only. This is what I am doing:
for (int i = 1; i < 6; i++)
{
if ((TextBox)Contr ols["textBoxBuy " + i.ToString()].Text.Length != 0) {}
}
The error that I am getting is:
Error 1 Cannot convert type 'int' to 'System.Windows .Forms.TextBox'
Can someone please help me out with this?
Thanks
Comment