ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Switch control
  • Overview of the Switch control
  • Creating a Switch control
  • Characteristics of Switch controls
  • "General" tab
  • "Style" tab
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview of the Switch control
Switch controls (also called "Toggle controls") are now commonly used in interfaces.
The Switch control is a 2-state Check Box control (on/off, true/false, yes/no). However, instead of checking a box, the user switches the cursor from right to left and vice versa to change the state:
  • the cursor moves when the control is clicked on.
  • the cursor can be moved using the mouse.
On touch screens (smartphones, etc.), the control reacts in a natural way (touch slide).
Examples of Switch controls in both possible positions
Examples of Switch controls in both possible positions
Creating a Switch control
To create a Switch control:
  1. On the "Creation" tab, in the "Usual controls" group, expand "Check Box".
  2. The list of available controls is displayed with the project skin template:
  3. Select the desired Switch control.
  4. Click where the control will be created in the window or page. The control appears in the editor.
To view the characteristics of the control, select "Description" in the context menu.
Characteristics of Switch controls
The description window of the Switch control is used to easily modify its characteristics:
  • The control display mode can be defined in the "General" tab
  • The look of the elements in the Switch control can be customized in the "Style" tab.

"General" tab

The following options are available in the "General" tab:
  • Display mode: Allows you to choose the presence and position of the options label to be displayed in the field.
    • presence of a caption:
      • if only one label is visible: the label is uncovered depending on whether you toggle left or right.
      • if both labels are visible: the label representing the current state is hightlighted by its style (font, color, size, etc.).
    • position of the caption(s):
      • internal: the label is displayed in the field on top of the background.
      • external: the label is displayed outside the field (on the right and/or left).
  • Caption alignment: Allows you to frame option labels. This option depends on the display mode chosen.
The "General" tab also allows you to enter the caption of the "ON" and "OFF" options and the corresponding value returned to the program. This value will be handled in the WLanguage code. By default, this value corresponds to 0 for the OFF value, and to 1 for the ON value (like a boolean). It is possible to return a value composed of numbers and/or letters. In this case, Value will not return the value as a boolean, but as a text value.
The "Forces the cursor width to take up half of the track" option allows you to use half the width of the control to draw the Switch control when the text is outside. This option is not valid if the captions are inside the control, on the background.

"Style" tab

The "Style" tab allows you to customize the style of the Switch control. It is possible to customize: the ON value and/or the OFF value for each field status.
In each case, different elements of the field can be customized: slider frame, cursor frame, etc.
for more details, see Customizing the Switch controls.
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/13/2025

Send a report | Local help