textBox.Numeric = true;

  • Thread starter Thread starter Patrick De Ridder
  • Start date Start date
P

Patrick De Ridder

MSDN shows the option: textBox1.Numeric = true; as a way to check that
the input in textBox1 is numeric. I cannot get it to work. How should
it be done?

Alternatively: looking at Validation in MSDN I see a check for an
Internet Address, I cannot convert the example to a check for Numeric
Input.

Please help.
 
Hi Patrick

All you have to do is override CreateParams property , below you will find
the code for this class, it's derived from TextBox and only redefine that
property.
Note, this do not check the value you create the control with, only the
input from the user.


public class NumericTextBox : TextBox

{

protected override CreateParams CreateParams

{

get

{

CreateParams cp = base.CreateParams;

cp.Style |= 0x2000; // ES_NUMBER ( defined in WinUser.h )

return cp;

}

}

}

Hope this help,
 
Hi Patrick

All you have to do is override CreateParams property , below you will find
the code for this class, it's derived from TextBox and only redefine that
property.
Note, this do not check the value you create the control with, only the
input from the user.


public class NumericTextBox : TextBox

{

protected override CreateParams CreateParams

{

get

{

CreateParams cp = base.CreateParams;

cp.Style |= 0x2000; // ES_NUMBER ( defined in WinUser.h )

return cp;

}

}

}

Hope this help,
*************************
What do you do after overriding the CreateParams?
How does this apply to eg textBox1?
 
Back
Top