NumericUpDown Box question(s)



I need some clarifications about your NumericUpDown Box

  1. When I set the decimal places to 0, I am still able to enter decimal numbers. How can I prevent this?
    The goal is to allow only integers
  2. How can I extend the NumericUpDown to show up with some prefix/postfix like currency, percentage or degrees
  3. In my database I save my percentage values in format p4, how can I bind the value to show up correct (Saved = 0,2 what should be 20%
  4. How can I show up values with it’s sign. -> When the value is “1” then it should become “+1,00”?
    In WinForms there was the possibility to set the Format to “+#0,00;-#0,00” then this worked fine

THX for every tip you have for me




  • You must to post comments

The javascript code you attached calls select() when a valid digit is typed:

 if ('+-1234567890'.indexOf(key) == -1)
    e.stop();  <--- this is when an invalid digit is pressed.
else;   <--- select() is not a valid function. "this" is a widget not an element.

should be:

 if ('+-1234567890'.indexOf(key) == -1){

  • You must to post comments


First of all: Thx for your solution. I extended it for my needs, but having trouble with a specific behaivour.

I changed the code from your sample with two little things to show you the problem. Not sure, if it is a bug or not.

I attached in JavaScript, that when a “wrong” value is inserted, then the whole text should be selected.

And in code behind: when the control gets entered, then also the whole text should be selected.

Now, when I enter the textbox, everything gets selected as expected. When the first input is a “wrong” (e.g. “a”) and then a correct value is used, then it get’s attached at the end and not overwritten:

The starting value = 0,00

When I enter a wrong and then 1 it becomes => 0,001 and it does not overwrite the 0,00 to => 1 as expected.

Could you please check, if this is a bug or a problem by my code!?

THX a lot – Have a nice start of the week


  • You must to post comments

Just checked in Winforms and I can’t see any way to format a NumericUpDown. In Winforms you can also type a decimal value when the Decimals property is set to zero, the result will be a number without decimals, which is correct. Wisej does exactly the same. NumericUpDown cannot be formatted using custom strings in Winforms and in Wisej – the text has to be parsed into a valid number on the client.

You can format a data bound TextBox control (like in Winforms) and use “p” for percentages or “+#0.00;-#0.00” to show +/-.

With Wisej you can also attach a javascript event to stop “.” or “,” from being typed and force only numeric characters.  And you can show a custom +/- button inside the field. You need to create a custom control.

I attached some sample code you can use and adapt to your requirements.



  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.