From 8373b14280b8e51ad88111d1dc2afcd370cc9f98 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Aug 2021 14:48:33 +0100 Subject: [PATCH] Add a wxGrid with numbers and dates to the internat sample Show that the numbers and dates in wxGrid use the expected formats. --- samples/internat/internat.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/samples/internat/internat.cpp b/samples/internat/internat.cpp index 2bd0af7af0..37baad345f 100644 --- a/samples/internat/internat.cpp +++ b/samples/internat/internat.cpp @@ -31,6 +31,7 @@ #include "wx/calctrl.h" #include "wx/intl.h" #include "wx/file.h" +#include "wx/grid.h" #include "wx/log.h" #include "wx/cmdline.h" #include "wx/numformatter.h" @@ -382,6 +383,23 @@ MyFrame::MyFrame() topSizer->Add(new wxCalendarCtrl(panel, wxID_ANY), wxSizerFlags().Center().Border()); + // another control using locale-specific number and date format + wxGrid* const grid = new wxGrid(panel, wxID_ANY, + wxDefaultPosition, wxDefaultSize, + wxBORDER_SIMPLE); + grid->CreateGrid(2, 2); + grid->HideRowLabels(); + + grid->SetColLabelValue(0, _("Number")); + grid->SetColFormatFloat(0); + grid->SetCellValue(0, 0, wxNumberFormatter::ToString(3.14159265, -1)); + + grid->SetColLabelValue(1, _("Date")); + grid->SetColFormatDate(1); + grid->SetCellValue(0, 1, "Today"); + + topSizer->Add(grid, wxSizerFlags().Center().Border()); + // show the difference between wxString::Format() and wxNumberFormatter: // the former uses the current C locale, while the latter uses the UI // locale