NumericUpDown

H

Hrvoje Voda

I have a numericUpDown control and I would like to limit the amount of
numbers entered after decimal place. Control has by default for decimal
places value 2, but I can write as many numbers as I want. I don't want to
do that.

Hrcko
 
B

Bruce Wood

First you have to decide how you want the user interaction to work.

When the user tries to type another decimal place beyond what you
specify, do you want nothing at all to happen? Or do you want the user
to be able to type the characters but then warn them when they are
finished?

In the first case, you could subclass the NumericUpDown class and
override (I think it's) the OnTextBoxKeyPress method to suppress any
keys you don't want to appear in the text box.

In the second case, you could handle the Validating event and warn the
user if what they have entered is not valid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top