NumericUpDown problem

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

(note: I'm using .NET 2.0)
If there is no text (and .Value has already been called) in my
NumericUpDown, I cannot set its property Value.

Demo:
- run the little attached program.
- press the button
- delete the value in the NumericUpDown
- press the button again: the text (of the NumericUpDown) is NOT updated!!!

Does anyone know a workaround this problem?
 
Lloyd,

There is no attached project, anyways it is not a good idea to post
attachements in the ng.

I tried to add NumericUpDown control to a from. I pressed the button it
increased the value. I delete the value in the edit box and pressed the
button again it new increased value showed up.

If this is the situation in your project my best guess is that you do
something else in the code.
 
Sorry, I forgot to attach it.
I don't see what the problem with a 500 bytes attached document, could you
explain it to me?
See for your self, there is no extra code, the NumericUpDown doesn't work as
described!
Or maybe only with 2.0 :-(

When I say press the button I mean an extra real (SWF.)Button (not one of
the 2 up/down button)
(and this button has a handler to set the .Value ot the NumericUpDown)
 
Lloyd Dupont said:
(note: I'm using .NET 2.0)
If there is no text (and .Value has already been called) in my
NumericUpDown, I cannot set its property Value.

Demo:
- run the little attached program.
- press the button
- delete the value in the NumericUpDown
- press the button again: the text (of the NumericUpDown) is NOT
updated!!!

Does anyone know a workaround this problem?

Num.Text = num.Value.ToString() works.

After you delete the 42 the Value property remains the same probably because
no entry is not a number so the 42 remains as the Value. This gives you the
chance to get the value before it was deleted. Because you are not changing
the Value when you set it to 42 the second time then the control is not
calling it's internal methods to cause the value to display as nothing has
really changed. You need to decide what "no entry" means in terms of a
numerical value and set the control's Text property to what you want
displayed, i.e. either 0 or to the Value.ToString(). Generally most controls
show 0 when you leave the control empty.

HTH

SP
 
funny that, when I try to type num.Text, the property Text doesn't appears
in VS.NET.
Somehow I imagined they used some kind of weird trick to make it
unavailable...
silly me, of course it compiles!

Thanks SP!
 
Back
Top