Hi All,
I'm having a problem with a NumericUpDown control. If the user highlights the number and hits the backspace key the number is, of course, erased. If the user then goes to another control in the dialog box, the number is still not displayed in the NumericUpDown. The value is still there - if the user hits the up or down arrows the number is incremented or decremented and is displayed correctly.
I tried to fix this by declaring a Leave event handler that does something to redraw or otherwise update the NumericUpDown display whenever it looses focus. I first tried using the Refresh() method, but that did nothing. I then tried calling Hide() followed immediately by Show(), and that also did't fix the problem.
Anyone know what I could do to make this work right?
Thanks!
Having trouble refreshing the display of a NumericUpDown control
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Tim Reiter5 pointsPosted Mar 13, 2008, 4:26 PM EDT
OK, I found that calling UpButton() and then DownButton() seems to work. Does anyone know of a more elegant, less cludgy solution?
Thanks again!
Karl Hiramoto2 pointsPosted Apr 16, 2009, 9:15 AM EDT
To display 123.
http://msdn.microsoft.com/en-us/library/cs40s7ds(VS.85).aspx
Looks like some kind of bug.
Scherzo2 pointsPosted Feb 27, 2012, 5:57 AM EST
Private Sub MyNumericUpDown_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyNumericUpDown.LostFocus
MyNumericUpDown.Text = MyNumericUpDown.Value
End Sub
So, when the control lost his focus, we always ensure that the .Text have the same value as .Value.
Scherzo