TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
marcfromm
NA
35
0
errorProvider
Nov 19 2004 5:53 PM
I created an errorProvider on an windows application to validate text boxes. It works great if I enter something values out side an int range. I cannot make it work if the box is blank or if I enter characters in the text box. How can errorProvider validate under these two conditions? private void buttonAccept_Click(object sender, System.EventArgs e) { int pick, totalPick, max; max = int.Parse(textBoxMax.Text); totalPick = int.Parse(textBoxPick.Text); pick = int.Parse(textBoxEnterNumber.Text); if (countNumber>=totalPick) { errorProvider.SetError(textBoxEnterNumber, "You have picked " + totalPick + " the numbers."); } else if (pick<1 || pick>max) { errorProvider.SetError(textBoxEnterNumber, "You must enter a number from 1 to " + max + "."); } //This does not work else if (textBoxEnterNumber.Text == "") { errorProvider.SetError(textBoxEnterNumber, "You must enter a number from 1 to " + max + "."); } else { countNumber++; numbers.Add(pick); textBoxEnterNumber.Clear(); textBoxMessages.Text += "Number" + (countNumber) + ": " + pick.ToString()+"\r\n"; errorProvider.SetError(textBoxEnterNumber, ""); } }
Reply
Answers (
3
)
Single instance of an Application in C#??
File Reading operation....