Recommended Answers
Jump to PostUse the Validated or Validating events of your textbox.
Something like:
private void Mytextbox_Validating(object sender,CancelEventAgrs e)
{
//check for int
//if not int:
// e.Cancel = true;
// MessageBox.Show("You need to enter an integer");
}
Jump to Postor you could use the numericupdown control :)
The code here is worth checking for the future if you need to validate string entries, but for numeric values the NumericUpDown control is much better. You can type directly into it if you dont want to use the arrows, you can …
Jump to PostAlso take a gander at this similar discussion for other techniques for accomplishing your goal: http://www.daniweb.com/forums/thread241075.html
All 9 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.