Validating Numericupdown control

G

Guest

I'm trying to create an app in VB.NET to run on CE/PocketPC. I've got a form
where it asks you for the date and time, auto-populating it with the current
date and time. The date and time shouldn't need to be changed by very much,
so I want to use a control that allows you to change the date and time by a
day or minute by using up/down arrows. The obvious solution to this was the
NumericUpDown control, which does exactly this (numbers rather than dates, so
I used several).

Unfortunately, the NumericUpDown isn't restricted to numeric data - the user
can type letters into it. On top of that, so far all my attempts to validate
it have failed. The Keypress and Keydown events don't seem to get fired so
you can't cancel the keypress, the Validating event doesn't pass the old and
new values of the control, so you can't reset it if the value is invalid and
there's no way to cancel the update. I tried writing my own date/time up-down
control, but when I try to incorporate it into my CE app the app won't
compile - I don't get any compile errors, it just runs through and then
fails. I'm assuming that's because it's a user control and the .NET compact
framework doesn't like it, although since all it is is a text box and scroll
bar with a bit of validation code behind it I really don't know why - I'm
don't think I used anything incompatible with the compact framework.

So, anyway, I was hoping someone had some suggestions as to how to either
validate the NumericUpDown, stop non-numeric entry to it (or any text entry
even, as long as it still allows selection using the up and down buttons) or
else get my user control working.

TIA
Ben
 

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