is there a way to show an empty DateTimePicker and have it populated when the mouse enters it (MouseEnter function)?
The question may also be:
How can I use the DateTimePicker’s Constructor ?
Apparently, it does not have any parameter.
I’m just curious why you would want it blank and not DateTime.Now as a starting point?
The Desktop.DateTime picker has no method to control whether it shows empty or not (as far as I understand). The only workaround would be to define the control’s font color the same as the control’s background. Looks like empty. Unfortunately, I do not (yet) know how to do this. The object does not expose a method for changing font properties.
You can place a rectangle over the DatePicker calendar sheet and put a
Me.Close in the
MouseEnter event of the Rectangle.
The reason is that I like it better if it shows empty rather than a default date. Personal preference.
Anyway, I used this technique: I set it to out of focus at Opening Event Handler until a MouseEnter. It’s dimmed, but not too bad looking. Unorthodox, for sure, but it’s the best I could come out with.
I for myself have the necessity of the possibility choosing a date Or letting the field blank representing an “open date” in intervals. Like Start date [05/12/2021] End date [ ] ← Means everything from start to the infinite. I have text field that I can ask a fld.ToDateTime() and when blank/empty/invalid I get Nil and If Nil I can consult fld.Empty() or fld.InvalidDate() or simply do things as If fld.ToDateTime()=Nil then fld.Text=""
It might be an idea, although I like the convenience of having a date picker instead of typing (if I read you correctly)
I’m just saying that I also have such need. So yes, having the OPTION to control the behavior and allow empty dates is very useful. Maybe if the control evolve a bit I could use it instead of my own. I need: typed intervention (masks may vary dd/mm/yyyy, dd/mm/yy, mm/dd/yyyy…), option to start blank or current date (and time), detection of invalid dates (empty is not invalid), detection of blank dates (isEmpty()), picking a calendar date, getting DateTime object or Nil (invalid/blank), getting SQLDate() (or “” if invalid/blank), getting SQLDateTime() (or “” if invalid/blank)