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

◆ checked() [1/2]

virtual bool xtd::forms::check_box::checked ( ) const
virtualnoexcept

Gets a value indicating whether the check_box is in the checked state.

Returns
true if the check_box is in the checked state; otherwise, false. The default value is false. If the three_state property is set to true, the checked property will return true for either a checked or indeterminate check_state.
Remarks
When the value is true, the check_box portion of the control displays a check mark. If the appearance property is set to button, the control will appear sunken when checked is true and raised like a standard button when false.
Examples
The following code example demonstrates the use of check_box checked.
#include <xtd/forms/application>
#include <xtd/forms/check_box>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::forms;
namespace check_box_example {
class form1 : public form {
public:
form1() {
text("Check box example");
controls().push_back_range({check_box1, check_box2, check_box3, check_box4, check_box5});
check_box1.auto_check(false);
check_box1.click += [&] {
// Uncomments next line to check / uncheck check box 1 (auto_check is false...)
//check_box1.checked(!check_box1.checked());
check_box1.text(string::format("{}", check_box1.check_state()));
};
check_box1.location({30, 30});
check_box1.text(string::format("{}", check_box1.check_state()));
check_box2.check_state_changed += [&] {
check_box2.text(string::format("{}", check_box2.check_state()));
};
check_box2.checked(true);
check_box2.location({30, 60});
check_box3.auto_size(true);
check_box3.check_state_changed += [&] {
check_box3.text(string::format("{}", check_box3.check_state()));
};
check_box3.check_state(forms::check_state::indeterminate);
check_box3.three_state(true);
check_box3.location({30, 90});
check_box4.appearance(forms::appearance::button);
check_box4.check_state_changed += [&] {
check_box4.text(string::format("{}", check_box4.check_state()));
};
check_box4.checked(true);
check_box4.location({30, 120});
check_box5.appearance(forms::appearance::button);
check_box5.auto_check(false);
check_box5.click += [&] {
// Uncomments next line to check / uncheck check box 5 (auto_check is false...)
//check_box5.checked(!check_box5.checked());
check_box5.text(string::format("{}", check_box5.check_state()));
};
check_box5.location({30, 150});
check_box5.text(string::format("{}", check_box5.check_state()));
}
private:
check_box check_box1;
check_box check_box2;
check_box check_box3;
check_box check_box4;
check_box check_box5;
};
}
auto main() -> int {
application::run(check_box_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 Windows check_box.
Definition check_box.h:45
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:54
@ 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
Examples
demo.cpp.