SetCtrlVal
- Updated2023-02-21
- 3 minute(s) read
int SetCtrlVal (int panelHandle, int controlID, ...);
Purpose
Sets the value of a control to a value you specify.
When you call SetCtrlVal on a list box or a ring control, SetCtrlVal sets the current list item to the first item that has the value you specify. To set the current list item through a zero-based index, use SetCtrlIndex.
When you call SetCtrlVal on a text box, SetCtrlVal appends value to the contents of the text box and scrolls the text box to display value. Use ResetTextBox to replace the contents of the text box with value.
![]() |
Note This function updates the displayed value immediately. Use SetCtrlAttribute with ATTR_CTRL_VAL to set the control value without immediately updating the displayed value. For this reason, SetCtrlAttribute with ATTR_CTRL_VAL is generally faster than SetCtrlVal. However, if the control in which you are setting the value is the active control in the panel, SetCtrlAttribute with ATTR_CTRL_VAL displays the value immediately. |
Supported Controls
You can use SetCtrlVal with binary switches, color numerics, LEDs, list boxes, numerics, picture buttons, picture rings, radio buttons, rings, numeric slides, ring slides, strings, text boxes, text buttons, text messages, toggle buttons, trees.
Parameters
Input | ||||||||||||||||||||||||||||||||||||||||
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||
panelHandle | int | Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel. | ||||||||||||||||||||||||||||||||||||||
controlID | int | The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by functions such as NewCtrl and DuplicateCtrl. | ||||||||||||||||||||||||||||||||||||||
value | ... | New value of the control. The data type of value must match the data type of the control.
|
Return Value
Name | Type | Description |
status | int | Return value indicating whether the function was successful. A negative number indicates that an error occurred. |
Additional Information
Library: User Interface Library
Include file: userint.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later
Example
Refer to userint\picture.cws for an example of using the SetCtrlVal function.