Disable Specific date in DateTimePicker

7 posts, 0 answers
  1. Daniel
    Daniel avatar
    17 posts
    Member since:
    Oct 2013

    Posted 12 May 2014 Link to this post

    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.
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 14 May 2014 Link to this post

    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.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Daniel
    Daniel avatar
    17 posts
    Member since:
    Oct 2013

    Posted 14 May 2014 in reply to Stefan Link to this post

    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? 
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 15 May 2014 Link to this post

    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.
     
  6. Daniel
    Daniel avatar
    17 posts
    Member since:
    Oct 2013

    Posted 15 May 2014 in reply to Stefan Link to this post

    Hello Stefan,

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

  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 15 May 2014 Link to this post

    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.
     
  8. Daniel
    Daniel avatar
    17 posts
    Member since:
    Oct 2013

    Posted 15 May 2014 in reply to Stefan Link to this post

    Hello Stefan,

    It work, just what i wanted. Thanks a lot. 
Back to Top
UI for WinForms is Visual Studio 2017 Ready