xtd 0.2.0
Loading...
Searching...
No Matches
control_with_name_operator.cpp

shows how to use xtd::forms::control::name property and xtd::forms::layout::arranged_element_collection::operator[] name operator.

Windows

macOS

Gnome

#include <xtd/xtd>
namespace control_with_name_operator_example {
class main_form : public form {
public:
main_form() {
controls().push_back_range({button1, label1});
button1.name("button1");
label1.name("label1");
controls()["button1"].value().get().location({10, 10});
controls()["button1"].value().get().text("Click me");
as<button>(controls()["button1"].value().get()).auto_repeat(true);
controls()["button1"].value().get().click += delegate_ {
static int count = 0;
controls()["label1"].value().get().text(string::format("button clicked {} times", ++count));
};
controls()["label1"].value().get().auto_size(true);
controls()["label1"].value().get().location({10, 50});
controls()["label1"].value().get().text("button clicked 0 times");
}
private:
button button1;
label label1;
};
}
auto main() -> int {
xtd::forms::application::run(control_with_name_operator_example::main_form {});
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:900