I will use a label with font color red just below the text box and will adopt the following code
private void textBox1_TextChanged(object sender, EventArgs e)
label1.Visible = false;
int n = int.Parse(textBox1.Text);
if (n > max || n < min)
label1.Text="Number can be only in range "+min.ToString()+" and "+max.ToString();
label1.Visible = true;
catch (Exception ex)
label1.Text = "Not a Number";
If you un-comment the comment lines, it will remove the last character, though label will not be visible(Also there is a small bug, the cursor will go to first position which can be set to last character).
gasshopper.iics is a group of like minded programmers and learners in codeproject. The basic objective is to keep in touch and be notified while a member contributes an article, to check out with technology and share what we know. We are the "students" of codeproject.
This group is managed by Rupam Das, an active author here. Other Notable members include Ranjan who extends his helping hands to invaluable number of authors in their articles and writes some great articles himself.
Rupam Das is mentor of Grasshopper Network,founder and CEO of Integrated Ideas Consultancy Services, a research consultancy firm in India. He has been part of projects in several technologies including Matlab, C#, Android, OpenCV, Drupal, Omnet++, legacy C, vb, gcc, NS-2, Arduino, Raspberry-PI. Off late he has made peace with the fact that he loves C# more than anything else but is still struck in legacy style of coding.
Rupam loves algorithm and prefers Image processing, Artificial Intelligence and Bio-medical Engineering over other technologies.
He is frustrated with his poor writing and "grammer" skills but happy that coding polishes these frustrations.