Ask/set Year for DatePicker


Année = Year

I really do not like this design.

The goal is to set a birth date.

People here adviced to use both DatePicker forms (two DatePicker), but I do not loved the design.

I add a Control named Année (Year) to seee how it looks… The idea is to let the user choose a year and click for the month/day.

In this situation, what design will you use:
DatePicker.Graphical (Day / Month) + DatePicker. that present day-month-year

Or

DatePicker.Graphical (Day / Month) Button to give the year from the keyboard ?


DatePicker.Graphical

image
Simple DatePicker display (*)

In both cases, there is code to add to set the year to the DatePicker.Graphical Control.

(*) I could use that alone, but it is not looking nice.

For setting a birthdate I wouldn’t even bother with the graphical variant and stick with the simple version. It’s the fastest for this kind of tasks. The graphical version is suitable for scheduling meetings and such, i.e. selecting dates close to the current date (or another set date). But I wouldn’t use it for selecting some arbitrary date in the (possibly distant) past or future.

The graphical picker is also useful whenever the day of the week is relevant (like for meetings). But your birthdate is what it is and you’ve got no choice anyway.

Worst: I could not found a way to change the Year of a DesktopDatePicker…
After a 10 minutes search. And a window to ask the year:

It is likely worth adding a bug report for the lack of setting a year in any useful way.

You, could, as a work around add a context menu that would list the years between MinimumDate and MaximumDate. Then you could change the date by right clicking on the control.

Online versions of the “graphical control” typically allow you to click on the year and a popup opens to allow you to select Month and Year. You could rig this up by using MouseDown / MouseUp within the top left area of the control and the new popup window option.

That is the ‘native’ macOS control.
On Windows there is a better native control.
We already talked about this in another thread where Emile asked the same thing (changing the year for a birthday date).
Xojo favors native controls I don’t think they will change what macOS offers.

Can you tell me of anything that uses that control for setting date. It used to be used by macOS settings but that only uses the non-graphical version in the latest version. I’m just interested to see what Apple have done about year when they are using it. Skipping month by month is super tedious.

Settings set Date and Time for example:

I think Emile should use Mac Contacts Birthday as an example of what to do:

I even was able to enter 13/45/23 and it changed to February 14, 2024.

I actually use Trhee popupMenus (Day - Month - Years).
I am not happy with that and…
… I have to deal with 28 / 29 / 30 / 31 by myself.

I canuse a TexTField with Mask, but I have to deal with the number of days in months…

Will this help?

DatePicker

Hmm… that’s interesting. The Xojo control doesn’t pop the graphical version up when you click in the non-graphical version. You could probably rig one with a popup window.

1 Like

Yes.

I’m watching some old Star Trek Voyager… :wink: to change my mind.

Drop by our website when you’re done :slight_smile:

In code you mean? You can set it to any date you like, including the year:

DateTimePicker1.SelectedDate = new DateTime(1959, 3, 5)

With the non-graphical variant of the DateTimePicker the user can simply type in any desired year (or day or month). What’s the problem you are trying to solve?

If you absolutely must use the graphical version for birthdates (which I wouldn’t, for the reasons explained above) you could combine it with the non-graphical picker and synchronize the two (like I’ve suggested a few weeks ago).

2 Likes

That where I was, when I stopped (forgot why; boring, maybe).

I may use a simple ask for a date (DD-MM-YYYY), pass the result to a DateTime at OK time and accept if the Date is valid / tell the user to retype the date otherwise…

I will decide what to do on Sunday.

Thank you for your report / suggestions.

With Xojo’s DateTimePicker (non-graphical style) the user could also type in day, month, and year, and it would be guaranteed you’d get a valid DateTime. Entering an invalid date would be impossible – no need to check the date in code.

1 Like

Thank you Michael,

You are correct. But I do not like it (too small, the users are oldsters).

I add a dedicated window to do just that with a nice icon and a bip if DateTime does not like it (in a Try Catch block as advertised in the Forul).

I am not fan to that point. For me, it’s just entertaining, but I love watching it.

Any news from the 202x series ? *[Strange New Worlds], Discovery, …Strange New Worlds…

You haven’t seen the clock :wink: