From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Rollback control change

I'm sure this question has been asked before, but I couldn't find the magic search words to locate it.  When the user changes the value of a control (let's just say a numeric control, but the same question applies to pretty much any editable control), I need to check the value they entered and determine if it's acceptable.  If it's not, I'm going to put up a message.  I'd also like to rollback the control to the original value.  Is there some easy way to do this without having to save the control value in a static variable, then restoring it manually?

 

Tony G.

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

Perhaps this help page on control events can help you a bit in designing your app.

The easiest solution for numeric controls is to set a range either in the UIR editor or programmatically (SetCtrlAttribute with ATTR_MIN_VALUE and ATTR_MAX_VALUE attributes) and set it in coerce mode, so that if the user enters a value out of range, it is clipped to the nearest limit and a EVENT_VAL_COERCED is sent to the control callback.

Alternatively you can set the control in Notify mode so that an alert sign is visible and use ValidatePanel to check if all controls are in-range or not.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(2,730 Views)