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

Disable Specific date in DateTimePicker

6 Answers 634 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 2
Daniel asked on 13 May 2014, 02:06 AM
Hello,

How can i disable, change font to red a specific day in DateTimePicker? For example, day 1, 3, 6, for the month of May.

6 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 14 May 2014, 12:18 PM
Hello Daniel,

Thank you for writing.

You can use the ElementRender event of the inner calendar to modify the appearance of the cells in the calendar:
void Calendar_ElementRender(object sender, RenderElementEventArgs e)
{
    if (e.Day.Date.Month == 5 && (e.Day.Date.Day == 1 || e.Day.Date.Day == 3 || e.Day.Date.Day == 6))
    {
        e.Element.ForeColor = Color.Red;
        //e.Element.Enabled = false;
    }
}

I hope this helps.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Daniel
Top achievements
Rank 2
answered on 15 May 2014, 12:43 AM
Hi Stefan,

Thanks for the reply. I'm using a RadDateTimePicker, if it is possible can you give me a sample on how i can disable and change forecolor to red a specific day in RadDateTimePicker? 
0
Stefan
Telerik team
answered on 15 May 2014, 05:59 AM
Hello,

The code provided is for RadDateTimePicker. Here is how to subscribe for it calendar event:
radDateTimePicker1.DateTimePickerElement.Calendar.ElementRender

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Daniel
Top achievements
Rank 2
answered on 15 May 2014, 06:33 AM
Hello Stefan,

i got red underline in Calendar, please see attached image. 

0
Stefan
Telerik team
answered on 15 May 2014, 10:44 AM
Hello Daniel,

The Calendar property has been introduced in our latest release (Q1 2014 SP1). For older versions, here is how to access the inner calendar: 
RadDateTimePickerCalendar calendarBehavior = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
RadCalendar calendar = calendarBehavior.Calendar as RadCalendar;

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Daniel
Top achievements
Rank 2
answered on 15 May 2014, 11:59 PM
Hello Stefan,

It work, just what i wanted. Thanks a lot. 
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Daniel
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Daniel
Top achievements
Rank 2
Share this question
or