Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling OutOfRange exception for Numeric Edit control in Winforms C#

Hello team,

 

I am trying to catch the NumericOutOfRangeMode exception when the user enters a value which is not with in the range.

The user can either click on the arrow buttons on the control or manually enter the value in the text box. I need to handle this exception by providing a custom message to the user gracefully.

But when the user manually enters the value in the textbox of the control and the control loses focus, I am not able to handle the exception because the value in the numeric edit shows the old value and the value entered in the textbox.

 

I tried using the BeforeChangeValue(), AfterChangeValue(), Leave(), Validating() and LostFocus() events of the control. These events get fired but the control does not reflect the value entered in the textbox, due to which I am not able to check the range condition and build a custom message.

 

 

0 Kudos
Message 1 of 2
(1,809 Views)

Seems the event BeforeChangeValue(object sender, NationalInstruments.UI.BeforeChangeNumericValueEventArgs e) helps me to handle this, found the below thread which had the details on handling this exception.

 

https://forums.ni.com/t5/Measurement-Studio-for-NET/Handling-out-of-range-exceptions-thrown-by-Numer...

0 Kudos
Message 2 of 2
(1,806 Views)