2
Answers

"ValueChanged" event triggers before value changes, another bug in C#?

M F

M F

16y
9.5k
1

This is getting annoying really <_<

I hope I'm wrong and this is just an issue with my code, cause I've already run into two bugs in C# today. I'm calling the "ValueChanged" event on a numericUpDown control, except whenever I press the up or down arrows on the control, the value passed from the event is the value the control was. For example if the control is 10, and I press the up arrow, it becomes 11, but the value passed back from "valueChanged" when I get the current value is 10.

Normally I'd just add 1, but when typing directly into the control and pressing enter, the valueChanged event returns the correct figure. So it would seem that someone took a shortcut while developing C#. When pressing the up arrow on a numericUpDown control the "valueChanged" event triggers on the button press, rather then  when the acctual event occurs.

I'm a tad annoyed as I've been working on this for the past few hours with no luck. I've tried other events as well, the validation event works, but occurs a tad after the button is pressed, and the lag time just isn't very nice in a GUI.

I'm hoping I'm just missing something simple. If anyone has any idea whats going on or a solution it would be much appreciated :)

Answers (2)