How to loop through windows form controls by name (C# / VB.NET)
ASP.NET dev have the advantage of FindControl, which does this work quite easily. For Windows forms developers the need to loop through the controls using ForEach in the control collection or can use the Find method as shown below:
foreach (Control ctl in Controls.Find("textBox" + i, false))
{
string stext = ctl.Text ;
};
Here we have used ControlCollection Controls.Find method to refer a Textbox and get the value
No comments:
Post a Comment