Empty NumericUpDown

  • Thread starter Thread starter neva
  • Start date Start date
N

neva

Hello,

I have a small problem ; I have found an alternate solution but I
don't like it.

The problem is simple, let's take a form, a numericUpDown inside and a
button that will show the value of the numericUpDown in a MessageBox
(or elsewhere, whatever).
Let's say you put '5' in the numericUpDown, click the button, "5", ok.
Now, erase the '5' in the numericUpDown, click the button, still "5"
but _nothing_ in the numericUpDown.

My problem is that I would like to catch when the user erases what's
inside the numericUpDown in order to put in the MinimumValue or just
display the actual Value.
Of course, I don't want it to be ReadOnly.

My alternate solution is to use numericUpDown.UpButton() then
numericUpDown.DownButton() but as I said, I don't like it.

If anyone has encountered the same problem and found a (better)
solution, I would like to read it.
Thanks,
 
handloe the validating event and use the text property. Text doesnt appear in
the intellisense but all controls have it so it does compile and work.

private void numericUpDown1_Validating(object sender, CancelEventArgs e)
{

if (numericUpDown1.Text == "")
{
numericUpDown1.Value = 0;
}
}
 
handloe the validating event and use the text property. Text doesnt appear in
the intellisense but all controls have it so it does compile and work.

private void numericUpDown1_Validating(object sender, CancelEventArgs e)
{

if (numericUpDown1.Text == "")
{
numericUpDown1.Value = 0;
}

}

Oh...
Thanks a lot Ciaran,
We learn things everyday
 
Back
Top