Why doesn't TDateTimePicker let me go to February?

I am using TDateTimePicker in my D7 application with the following properties:

Format = 'MMM-yyyy'
DateMode = dmUpDown

When I try to set the current time for it using dt1.DateTime := Now, it sets the time and date correctly, but at the same time I see an exception when I try to move around the months. In particular, I cannot spread below the month of March.

What causes this problem?

+5
source share
1 answer

The problem is that the date time picker is initialized to the current date. And this includes the day of the month, which is not valid for several months.

, , 29 2013 . / , , 2013 29 .

, , , :

DateTimePicker1.Format := 'MMM-yyyy';
DateTimePicker1.DateMode := dmUpDown;
DateTimePicker1.DateTime := EncodeDateTime(2013, 1, 29, 0, 0, 0, 0);

, , DateTime . , :

DateTimePicker1.DateTime := StartOfTheMonth(DateTimePicker1.DateTime);

, , :

DateTimePicker1.DateTime := StartOfTheMonth(Date);

StartOfTheMonth DateUtils.

+14

All Articles