Under certain conditions I'd like to cancel the ValueChanged event of a NumericUpDown control in Winforms (e.g. when the value set in the control is too high in relation to another value in a TextBox).
However, the EventArgs passed as argument into the event handler for the NumericUpDown control doesn't offer anything like "Cancel", so how can I do it?
private void nudMyControl_ValueChanged(object sender, EventArgs e)
{
// Do some stuff, but only if the value is within a certain range.
// Otherwise, cancel without doing anything.
}
You probably can handle this situation by using
Minimum&maximumProperties, yet there are some solutions.One way to do it is by creating a custom control, although it is nasty in my idea.
You also can do stuff for
ValueChanged:This is some dummy sample, yet you can change it in your way: