xtd 0.2.0
Loading...
Searching...
No Matches

◆ check_state() [1/2]

virtual forms::check_state xtd::forms::light_button::check_state ( ) const
virtualnoexcept

Gets the state of the light_button.

Returns
One of the check_state enumeration values. The default value is unchecked.
Remarks
If the three_state property is set to false, the check_state property value can only be set to check_state::indeterminate in code and not by u ser interaction.
The following table describes the xtd::forms::appearance of the light_button control in its different states for the normal and button style control light_button::appearance.
Check_state appearance::normal appearance::button
checked The light_button displays a light on. The control appears sunken.
unchecked The light_button displays a light off. The control appears raised.
indeterminate The light_button displays a light on and is shaded. The control appears flat.
Examples
The following code example demonstrates the use of light_button check_state.
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/light_button>
using namespace xtd;
using namespace xtd::forms;
namespace light_button_example {
class form1 : public form {
public:
form1() {
text("Light button example");
controls().push_back_range({light_button1, light_button2, light_button3});
light_button1.auto_check(false);
light_button1.click += [&] {
//light_button1.checked(!light_button1.checked());
light_button1.text(string::format("{}", light_button1.check_state()));
};
light_button1.location({30, 30});
light_button1.text(string::format("{}", light_button1.check_state()));
light_button1.width(130);
light_button2.check_state_changed += [&] {
light_button2.text(string::format("{}", light_button2.check_state()));
};
light_button2.checked(true);
light_button2.location({30, 80});
light_button2.width(130);
light_button3.auto_size(true);
light_button3.check_state_changed += [&] {
light_button3.text(string::format("{}", light_button3.check_state()));
};
light_button3.check_state(forms::check_state::indeterminate);
light_button3.three_state(true);
light_button3.location({30, 130});
light_button3.width(130);
}
private:
light_button light_button1;
light_button light_button2;
light_button light_button3;
};
}
auto main() -> int {
application::run(light_button_example::form1 {});
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
static void enable_visual_styles()
Enables visual styles for the application.
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:54
Represents a Windows light_button.
Definition light_button.h:45
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10