range validation for textbox in c# windows application
  • how can i validate that user should enter number in textbox just in specific range. like i set one textbox for get percentage so user should enter number between 1 to 100.
  • 1 Comment sorted by
  • Vote Up0Vote Down aftabaftab
    24.50 Karma Accepted Answer
    you can use textbox's Validating Event .

     private void textBox1_Validating(object sender, CancelEventArgs e)
    decimal Input = Convert.ToDecimal(textBox1.Text);
    if (Input < 1 || Input > 100)
    MessageBox.Show("Input number should be between 1 to 100", "codingresolved.com");
    e.Cancel = true;

    Source : http://codingresolved.com/discussion/1007/textbox-minimum-and-maximum-number-range-in-c/p1

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook


Popular Posts of the Week

    Optimum Creative