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

demonstrates the use of xtd::forms::date_time_picker dialog.

Windows

macOS

Gnome

#include <chrono>
#include <xtd/forms/application>
#include <xtd/forms/date_time_picker>
#include <xtd/forms/form>
#include <xtd/forms/label>
using namespace std::chrono;
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Date time picker example");
controls().push_back_range({picker1, label1, picker2, label2});
picker1.location({30, 30});
picker1.format(date_time_picker_format::short_format);
picker1.value_changed += [&] {
label1.text(picker1.value().to_short_date_string());
};
picker1.value(date_time::now());
picker1.max_date(picker1.value().add(months(3)));
picker1.min_date(picker1.value().add(months(-3)));
label1.location({30, 70});
label1.size({380, 30});
picker2.location({30, 110});
picker2.format(date_time_picker_format::time);
picker2.value_changed += [&] {
label2.text(picker2.value().to_long_time_string());
};
picker2.value(date_time::now());
picker2.max_date(picker2.value().add(hours(3)));
picker2.min_date(picker2.value().add(hours(-3)));
label2.location({30, 150});
label2.size({380, 30});
}
private:
label label1;
label label2;
};
auto main()->int {
application::run(form1 {});
}
Represents a picker control that displays available date time along with controls.
Definition date_time_picker.h:31
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:52
Represents a standard Windows label.
Definition label.h:36
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