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
choice.cpp

The following code example demonstrate the use of choice control.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace examples {
class form1 : public form {
public:
form1() {
text("Choice example");
choice1.parent(*this);
choice1.location({10, 10});
choice1.items().push_back_range({"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10"});
choice1.selected_index(0);
choice1.selected_index_changed += event_handler(*this, &form1::on_choice_click);
choice2.parent(*this);
choice2.location({10, 50});
choice2.items().push_back_range({"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10"});
choice2.selected_index(0);
choice2.selected_index_changed += event_handler(*this, &form1::on_choice_click);
}
private:
void on_choice_click(object& sender, const xtd::event_args& e) {
choice1.selected_index(as<choice&>(sender).selected_index());
choice2.selected_index(as<choice&>(sender).selected_index());
}
choice choice1;
choice choice2;
};
}
int main() {
application::run(examples::form1());
}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Represents a choice control.
Definition: choice.h:25
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition: event_handler.h:33
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition: bitmap.h:11
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