NumericUpDown

G

Guest

Hi,

I have a form with a TextBox and a NumericUpDown on it. NumericUpDown's
CausesValidation is true. I subscribe for NumericUpDown.ValueChanged. I
experience the following problem:
If I change the value from arrows, the ValueChanged event is fired as
expected.
If I enter value in NumericUpdown from keyboard (not arrows) and I press
ENTER, the ValueChanged event is fired as expected.
If I enter value in NumericUpDown from keyboard (not arrows) and I simply
move the focus to the text box by pressing TAB or simply clicking on the text
box with the mouse the ValueChanged event is NOT fired. Is this behaviour as
expected?
How do I get notification when the value gets changed no matter how?
I also noticed that when I change the value of NumericUpDown from from
keyboard (not arrows) the event is not fired but if I change from arrows
after that, the event fires twice

Thanks
 
T

Tim Scott

It seems like there should be a better way, but you could handle both
ValueChanged and the Control.Validated events. Validated is raised
when the TextBox in the NumericUpDown loses focus (but is raised
regardless if the value changed).

You could also derive your own control from NumericUpDown and override
the OnTextBoxTextChanged method. This is called whenever the text in
the TextBox changes (and even if the Value itself isn't changing).

I haven't figured out why the ValueChanged event isn't raised when you
expect it...

Hope this helps,

-- Tim S.
 

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