You can use the Validating event to validate the contents of the TextBox.
User can't select anything and even not close the form while the contents is
not validated.
textBox1.Validating += new
System.ComponentModel.CancelEventHandler(textBox1_ Validating);
private void textBox1_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{
e.Cancel = !Regex.IsMatch(textBox1.Text, "[0-9]*");
}
"volume" <a@a.com> wrote in message
news:ek**************@TK2MSFTNGP14.phx.gbl...
Restricting a windows textbox (edit item) to digits only.
Is there a windows option, using .NET C#, to only allow a user to enter
digits ONLY? If so, what is the flag or setting? If no, what is the best
method to manually and robustly do it?
I have a windows form with an editbox that I only want user's to enter
digits.
Thanks in advance.