Setting the Calendar date

1 Answer 20 Views
Calendar, DateTimePicker, TimePicker and Clock
Dave
Top achievements
Rank 2
Iron
Iron
Iron
Dave asked on 06 Mar 2025, 01:38 PM

I want to set the selected date of the Calendar, like with the DateTimePicker.

The SelectedDate property, which allegedly has a getter and setter, does not seem to work.

radDateTimePicker1.Value = DateTime.Now.AddDays(-3);  // This works great. The picker displays the date from three days ago.

radCalendar1.SelectedDate = DateTime.Now.AddDays(-3); // This shows today's date.

What am I missing?

TIA!

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 06 Mar 2025, 01:59 PM

Hello, Dave,

You should set the FocusedDate property:

radCalendar1.FocusedDate = DateTime.Now.AddDays(-3);

Also, by default, RadCalendar indicates the current day with a border in the Fluent theme. If you want to eliminate this current date's indication, it is suitable to use the ElementRender event:

private void RadCalendar1_ElementRender(object sender, RenderElementEventArgs e)
{
    if (e.Day.Date == DateTime.Today)
        e.Element.DrawBorder = false;
    else
        e.Element.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
}

I hope this helps. Please let me know if you have other questions.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Dave
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or