I have a series of labels / textboxes within a form.
How do I quickly access one of these according to the name of the component ?
Currently we use syntax similar to the following :
for (int i=0; i<panel1.Controls.Count;i++)
{
if (panel1.Controls.Name.ToString() == "TextBox1"
{
// We now know we are dealing with TextBox1 component
}
}
Is there a more direct way of doing this ?
Would the Tag's against the components be a quicker way of finding things ?
Within Borland Delphi I recall the 'FindComponent' function which allowed a quick handle to the component in question (by name I think) - is there an equivalent in C# ?
I'm not asking because the current method is slow - it just feels there should be a more direct route.
Any suggestions would be appreciated.
Thanks in advance
Steve
How do I quickly access one of these according to the name of the component ?
Currently we use syntax similar to the following :
for (int i=0; i<panel1.Controls.Count;i++)
{
if (panel1.Controls.Name.ToString() == "TextBox1"
{
// We now know we are dealing with TextBox1 component
}
}
Is there a more direct way of doing this ?
Would the Tag's against the components be a quicker way of finding things ?
Within Borland Delphi I recall the 'FindComponent' function which allowed a quick handle to the component in question (by name I think) - is there an equivalent in C# ?
I'm not asking because the current method is slow - it just feels there should be a more direct route.
Any suggestions would be appreciated.
Thanks in advance
Steve