Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How can I check validation in winfrom text Box in c#?
Posted

C#
if (textBox1.Text.Trim() == "")
            {
                MessageBox.Show("Insert Your Message");
            }
            else if (textBox2.Text.Trim() == "")
            {
                MessageBox.Show("Insert Your Message");
            }
 
Share this answer
 
There are a couple of ways, but the basic methods are to handle either the TextChanged event (if you want to prevent any invalid entry) or the Validating event (if you want to check it when the user is finished)

In either case, you can then check the Text property against your criteria.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900