I’m building an application which basically has a lot of user input, text boxes, combo boxes etc. I came across a problem involving input validation, and basically my solution was to call a method(which checks textbox input) within the timer.tick method.
The method:
private void AllowCreate()
{
if (firstNameText.Text == String.Empty || lastNameText.Text == String.Empty
|| descriptionText.Text == String.Empty)
{
createButton.Enabled = false;
}
else
{
createButton.Enabled = true;
}
}
So every tick, the method is called and checks if the text boxes are empty.
My question is: Is using a timer in this way, good practice? If not, are there more efficient ways of accomplishing what I am trying to do? Thanks.
I would not use these method.
I always catch
TextChangedevent for TextBoxes andSelectedIndexChangedfor ComboBoxes and call check routine from there, enabling or disabling the button.Basically, if you send all the events to
you’ve done.