ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Switch control
  • Overview
  • Initializing a Switch control
  • Retrieving the value of a Switch control
  • Properties specific to Switch controls
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Handling a Switch control through programming
Overview
WINDEV, WINDEV Mobile and WEBDEV allow you to handle a Switch control through programming. Simply use the variable of the Switch control in the code.
The variable of the Switch control corresponds to the name of the control. This variable is an integer.
This help page explains how to handle a Switch control through programming.
Initializing a Switch control
The Switch control is a control that proposes only two choices: ON and OFF. The first option of the switch corresponds to OFF and the second option corresponds to ON.
By default, when it is displayed, the Switch control is set to OFF.
To set the switch to ON, you can use:
  • the direct assignment. In this case, simply specify the returned value corresponding to the desired choice through programming. This value has been defined in the "General"' tab of the control description window.
    <Switch control> = 1 // If the value returned is 1
    <Switch control> = True // If the value returned is True
    <Switch control> = "Option 2" // If the value returned is Option 2
  • the Value property.
    Switch control>.Value = 1 // If the value returned is 1
    Switch control>.Value = True // If the value returned is True
    Switch control>.Value = "Option 2" // If the value returned is Option 2
Remark: If the control is associated with a data file item, the assignment is automatically performed via:
Retrieving the value of a Switch control
To retrieve the value if a Switch control, use the following syntax:
<Control value> = <Switch control>
In this case, <Control value> corresponds to the value returned by each one of the choices in the control description window.
The value returned by each option (OFF and ON) can be changed programmatically with the ReturnedValue property. For example:
Switch control>[1].ReturnedValue = <Value for option OFF
Switch control>[2].ReturnedValue = <Value for option ON
Reminder: The first option of the switch corresponds to OFF and the second option corresponds to ON.
Remark: If the control is associated with a data file item, the entered value is automatically retrieved via:
Properties specific to Switch controls
The Switch control can be manipulated via the WLanguage properties.
For a complete list of WLanguage properties that can be used with a Switch control, see Properties associated with a Switch control.
Remark: to change the colors or appearance of the control when moving the cursor, it is necessary to configure the style of the control elements ( "Style" tab of the control description window).
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help