This is a migrated thread and some comments may be shown as answers.

Losing Focus without expanding DateTimePicker populates today's date as value

0 Answers 19 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Priyam
Top achievements
Rank 1
Priyam asked on 21 Jan 2014, 04:58 PM
When I tab through the controls in my form, and while tabbing through datetime picker Current Date is populated as value. I do not want to the control to enter any date without user selection. Also, I have a pair of datetime picker like start date and end date and each is of the control's Opened & Leave Events are utilized as below but without these also, the same issue occurs.
private void dtProdStartDate_Leave(object sender, EventArgs e)
        {
            if (dtProdEndDate.Text == String.Empty && dtProdStartDate.Value != DateTime.Parse("1/1/0001"))
            {
                DateTime dtStart = dtProdStartDate.Value;
                dtStart = dtStart.AddMonths(1);
                DateTime dtEnd = dtStart.AddDays(-dtStart.Day);
                dtProdEndDate.Value = dtEnd;
            }
            else
            {
                if (DateTime.Compare(dtProdStartDate.Value, dtProdEndDate.Value) > 0)
                {
                    DateTime dtStart = dtProdStartDate.Value;
                    dtStart = dtStart.AddMonths(1);
                    DateTime dtEnd = dtStart.AddDays(-dtStart.Day);
                    dtProdEndDate.Value = dtEnd;
                }
            }
        }
 
 private void dtProdStartDate_Opened(object sender, EventArgs e)
        {
            if (this.dtProdStartDate.Value == DateTime.MinValue)
            {
                ((RadDateTimePickerCalendar)this.dtProdStartDate.DateTimePickerElement.GetCurrentBehavior()).Calendar.FocusedDate = DateTime.Now;
            }
        }

No answers yet. Maybe you can help?

Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Priyam
Top achievements
Rank 1
Share this question
or