Assigning event TextChanged to all textboxes in Form
Hello I was wondering how can I keep an eye on all textboxes in Form
whether in any of them was changed value. I saw some code here
private void Form1_Load(object sender, EventArgs e)
{
foreach (Control ctrl in this.Controls)
{
if (ctrl is TextBox)
{
TextBox tb = (TextBox)ctrl;
tb.TextChanged += new EventHandler(tb_TextChanged);
}
}
}
void tb_TextChanged(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
tb.Tag = "CHANGED"; // or whatever
}
And a guy who wrote this code says that it can`t be assigned to textboxes
in Panels and Grouboxes.
So my answer is as I have almost every textbox in groubox or panel, how
can I see whether change was made for textboxes in panels or groupbox?
Thank you for your time.
No comments:
Post a Comment