I want to clear all values on a form where the control is a label and its name starts with "label"
This code:
List<Label> lbls = this.Controls.OfType<Label>().ToList();
foreach (var lbl in lbls)
{
if (lbl.Name.StartsWith("label"))
{
lbl.Text = string.Empty;
}
}
...doesn't work, because the lambda is finding nothing - lbls.Count = 0.
Wouldn't this get ALL the controls on the form, even those that are children of other controls (such as, in my case, Panels)?