xtd 0.2.0
combo_box.cpp

demonstrates the use of xtd::forms::combo_box control.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/combo_box>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace combo_box_example {
class form1 : public form {
public:
form1() {
controls().push_back_range({combo_box1, combo_box2, combo_box3});
text("Combo box example");
combo_box1.location({10, 10});
combo_box1.items().push_back_range({"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10"});
combo_box1.selected_index(0);
combo_box1.selected_index_changed += event_handler(*this, &form1::on_combo_box_selected_index_changed);
combo_box2.location({10, 50});
combo_box2.drop_down_style(combo_box_style::drop_down_list);
combo_box2.items().push_back_range({"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10"});
combo_box2.selected_index(0);
combo_box2.selected_index_changed += event_handler(*this, &form1::on_combo_box_selected_index_changed);
combo_box3.location({10, 90});
combo_box3.drop_down_style(combo_box_style::simple);
combo_box3.items().push_back_range({"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10"});
combo_box3.selected_index(0);
combo_box3.selected_index_changed += event_handler(*this, &form1::on_combo_box_selected_index_changed);
}
private:
void on_combo_box_selected_index_changed(object& sender, const xtd::event_args& e) {
combo_box1.selected_index(as<combo_box&>(sender).selected_index());
combo_box2.selected_index(as<combo_box&>(sender).selected_index());
combo_box3.selected_index(as<combo_box&>(sender).selected_index());
}
combo_box combo_box1;
combo_box combo_box2;
combo_box combo_box3;
};
}
auto main() -> int {
application::run(combo_box_example::form1 {});
}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a Windows combo box control.
Definition combo_box.hpp:36
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
@ e
The E key.
Definition console_key.hpp:96
@ drop_down_list
Specifies that the list is displayed by clicking the down arrow and that the text portion is not edit...
Definition combo_box_style.hpp:30
@ simple
Specifies that the list is always visible and that the text portion is editable. This means that the ...
Definition combo_box_style.hpp:26
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8