DADiSP Worksheet Functions > Function Categories > Menu Functions > SETCONTROLVALUE
Sets the value of a control in a custom dialog box.
SETCONTROLVALUE(id, value, update)
id |
- |
An integer, the numeric ID of the target control. |
value |
- |
An integer or string, the value to set. |
update |
- |
Optional. An integer, update the visual display of the control. Defaults to 1, update. |
Nothing, the control is set to the new value.
Consider the following dialog box specification:
// dlg1.pan
@dialog
SetcontrolValue
{defvar("ctrlval", 0)}
Integer: <id=100 w=15>~ctrval = <{ctrlval}>~input(2)
<L>
Up <b >~~ctrlval++;setcontrolvalue(100, ctrlval);
Down <b x=-1 y=-1>~~ctrlval--;setcontrolvalue(100, ctrlval);
Clear <b x=-1 y=-1>~~ctrlval=0;setcontrolvalue(100, ctrlval);
<L>
The dialog is invoked with MENUFILE:
menufile("dlg1.pan")
The Up button increments the crtlval variable and updates the control in the Integer field. Down decrements the control and Clear resets the value to 0. Each button sets the control directly without the need to reload and refresh the menu.
In this case, a similar update effect can be achieved with the # property:
// dlg2.pan
@dialog
SetcontrolValue
{defvar("ctrlval", 0)}
Integer: <id=100 w=15>~ctrval = <{ctrlval}>~input(2)
<L>
Up <# b >~~ctrlval++
Down <# b x=-1 y=-1>~~ctrlval--
Clear <# b x=-1 y=-1>~~ctrlval=0
<L>
However, unlike SETCONTROLVALUE, the # property causes the entire dialog to reload and refresh each time the value of the field changes.
Use SETCONTROLVALUE to set the value of a control directly without reloading the menu.
The control must be referenced by a valid integer ID, set by the id property.
Most controls always update with the new value. The update parameter can determine the visual updating of some controls such as editable comboboxes and checkbox lists. In particular for a combobox, the update parameter sets the following update behavior:
1: |
update normally |
2: |
update edit box selection |
3: |
update edit box selection for non-editable combobox |
See GETCONTROLVALUE to obtain the value of a control as a string.
See Creating DADiSP Menus for more details on dialog box creation and implementation.