Hello.
I'm writing Windows Form App and I found "tiny" trouble. I can't manage with finding control by a name.
I have this code:
private Control FindByName(string name)
{
foreach (Control c in this.Controls)
{
if (c.Name == name)
return c;
}
return null;
}
and simply it doesn't return me what I want.
I have on my form TextBox named "diamond".
The code:
Control tb = FindControlByName("diamond");
tb.Text = "...";
returns me an exception: NullReferenceException.
Moreover I don't have method "AppendText" which is specific to TextBox.
What's wrong?