I have a form with many labels and text boxes. I'd like to have the title highlighted red if any of the fields are modified. Is there an easy way to do this or do you need to add the event callback to each form object individually? Thanks!
Off the top of my head you could do something like this in the form load event to add the events...
foreach (var control in this.Controls)
{
if (control is Label)
{
((Label)control).TextChanged += Controls_TextChanged;
}
else if (control is TextBox)
{
((TextBox)control).TextChanged += Controls_TextChanged;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With