xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
switch_button.cpp

The following code example demonstrate the use of switch button control.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace std;
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Switch button example");
switch_button1.auto_check(false);
switch_button1.parent(*this);
switch_button1.location({50, 30});
switch_button1.click += [&] {
//switch_button1.checked(!switch_button1.checked());
};
switch_button2.parent(*this);
switch_button2.location({50, 70});
switch_button2.checked_changed += [&] {
label1.text(ustring::format("switch: {}", switch_button2.checked() ? "On" : "Off"));
};
switch_button2.checked(true);
label1.parent(*this);
label1.location({50, 110});
label1.auto_size(true);
}
private:
switch_button switch_button1;
switch_button switch_button2;
label label1;
};
int main() {
application::run(form1());
}
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
Represents a standard Windows label.
Definition: label.h:26
Represents a standard Windows switch button.
Definition: switch_button.h:19
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17