I need to change the behaviour of NumericUpDown (compact framework 2.0) so
that I can show a dialog stating that the value is not within the allowed
range rather than just capping the input value. Any ideas how I can achieve
this? I don't seem able to find a suitable place to hook into (pre
set-value).


Thanks


Pete

Re: NumericUpDown by John

John
Thu Jul 17 09:48:27 CDT 2008

Not sure if I completely understand your question, but:

private void numericUpDown1_ValueChanged(object sender,
EventArgs e)
{
if (this.numericUpDown1.Value > 5)
{
MessageBox.Show("Value cannot be greater than 5");
this.numericUpDown1.Value = 5;
}
}

Seems to work fine for me.



"Peter Morris" <mrpmorrisNO@SPAMgmail.com> wrote in message
news:O$TCOWB6IHA.5108@TK2MSFTNGP06.phx.gbl:

> I need to change the behaviour of NumericUpDown (compact framework 2.0) so
> that I can show a dialog stating that the value is not within the allowed
> range rather than just capping the input value. Any ideas how I can achieve
> this? I don't seem able to find a suitable place to hook into (pre
> set-value).
>
>
> Thanks
>
>
> Pete


Re: NumericUpDown by Peter

Peter
Thu Jul 17 09:55:54 CDT 2008

That occurs after the value has changed, as a consequence the property on
the object it is bound to has already been set and thrown an out of range
exception. I need something which occurs before the value is set. The
Validating event is not executed though.


Re: NumericUpDown by Peter

Peter
Thu Jul 17 11:26:45 CDT 2008

I think I have solved it, it was quite a complicated process. I will blog
about it at some point and post the solution here.


Pete


Re: NumericUpDown by Peter


Re: NumericUpDown by Peter

Peter
Sat Jul 19 05:16:40 CDT 2008

Any recommendations on preventing the loss of focus rather than forcing
focus back when the value is invalid?