C# timer control - good practice?

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;
            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 TextChanged event for TextBoxes and SelectedIndexChanged for ComboBoxes and call check routine from there, enabling or disabling the button.

Basically, if you send all the events to

private void Something_Changed(object sender, EventArgs e)
    createButton.Enabled = 
        !String.IsNullOrEmpty(firstNameText.Text) &&
        !String.IsNullOrEmpty(lastNameText.Text) &&

you've done.

Need Your Help

How to stop form submit from going into a loop?

javascript jquery

This is the current situation, and the code is self explanatory.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.