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

The following code example demonstrate the use of list_box 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("List box example");
client_size({360, 240});
layout_panel.parent(*this);
layout_panel.controls().push_back_range({list_box_left, list_box_right});
layout_panel.control_layout_style(list_box_left, {size_type::auto_size, true});
layout_panel.control_layout_style(list_box_right, {size_type::auto_size, true});
layout_panel.dock(dock_style::fill);
layout_panel.padding(forms::padding(20));
list_box_left.double_click += [&] {
if (list_box_left.selected_index() != list_box_left.npos) {
list_box_right.items().push_back(list_box_left.selected_item());
list_box_right.selected_index(0);
list_box_left.items().erase_at(list_box_left.selected_index());
}
};
list_box_right.sorted(true);
list_box_right.double_click += [&] {
if (list_box_right.selected_index() != list_box_right.npos) {
list_box_left.items().push_back(list_box_right.selected_item());
list_box_left.selected_index(0);
list_box_right.items().erase_at(list_box_right.selected_index());
}
};
list_box_left.items().push_back_range({"draw", "cut", "paste", "delete", "open", "close", "remove", "edit", "find", "increment", "decrement", "write", "read", "post", "build", "make", "release", "create", "choose", "erase"});
list_box_left.selected_index(0);
}
private:
list_box list_box_left;
list_box list_box_right;
};
}
int main() {
application::run(examples::form1());
}
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
Used to group collections of horizontally aligned controls.
Definition: horizontal_layout_panel.h:21
Represents a standard Windows list box.
Definition: list_box.h:23
Represents a display device or multiple display devices on a single system.
Definition: padding.h:20
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