Thank you nobugz. You rock!
I really appreciate you taking the time to inlclude the code. Definitely takes the guess work out for beginners!
Had a little issue with this line of code:
Control lbl = ctl.Parent.Controls[lblName] as Control;
It won't alllow meto reference controls by their string name. It needed the int value of the control in the collection.
So I just wrote some code to loop through the code to retrieve the control.
public static Control GetControlByName(string name, Control Controls)
{
foreach (Control ctrl in Controls.Parent.Controls)
{
if (ctrl.Name == name)
return ctrl;
}
return null;
}
thus replacing your the linethat threw the error with:
Control lbl = GetControlByName(lblName, ctl);
Works perfectly now! Wouldn't be possible without your help.