DateTimePicker: Make available just a few days

2 posts, 0 answers
  1. Marc
    Marc avatar
    48 posts
    Member since:
    Mar 2017

    Posted 02 Oct 2018 Link to this post

    Hey,

    I want to make available just the 1st and the 15th of a month.

    How can I get this?

     

    Regards

  2. Dimitar
    Admin
    Dimitar avatar
    2769 posts

    Posted 02 Oct 2018 Link to this post

    Hi Marc,

    You can use the ElementRender event to disable the dates. Here is an example:
    public RadForm1()
    {
        InitializeComponent();
        radDateTimePicker1.DateTimePickerElement.Calendar.ElementRender += Calendar_ElementRender;
    }
     
    private void Calendar_ElementRender(object sender, Telerik.WinControls.UI.RenderElementEventArgs e)
    {
        if (e.Day.Date.Day != 1 && e.Day.Date.Day != 15)
        {
            e.Element.Enabled = false;
        }
        else
        {
            e.Element.Enabled = true;
        }
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top