textBox.Numeric = true;

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick De Ridder

    #1

    textBox.Numeric = true;

    MSDN shows the option: textBox1.Numeri c = 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.
    --
    Regards,
    Patrick.
  • Ignacio Machin

    #2
    Re: textBox.Numeric = true;

    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.CreatePara ms;

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

    return cp;

    }

    }

    }

    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    "Patrick De Ridder" <patrick_de_rid der@hetnet.nl> wrote in message
    news:puchlvoci6 n5omhjrvregvf73 18oergpl0@4ax.c om...[color=blue]
    > MSDN shows the option: textBox1.Numeri c = 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.
    > --
    > Regards,
    > Patrick.[/color]


    Comment

    • Patrick De Ridder

      #3
      Re: textBox.Numeric = true;

      On Fri, 5 Sep 2003 15:35:57 -0400, "Ignacio Machin" <ignacio.mach in AT
      dot.state.fl.us > wrote:
      [color=blue]
      >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.CreatePara ms;
      >
      >cp.Style |= 0x2000; // ES_NUMBER ( defined in WinUser.h )
      >
      >return cp;
      >
      >}
      >
      >}
      >
      >}
      >
      >Hope this help,[/color]
      *************** **********
      What do you do after overriding the CreateParams?
      How does this apply to eg textBox1?
      --
      Regards,
      Patrick.

      Comment

      Working...