Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1075
UltraDateTimeEditor - bolding dates?
posted

 Is it possible to mark bold some dates in DateTimeEditors's calendar? Like paint all Saturdays and Sundays with red or bold? Can you disable dates after today to pick up?

Parents
  • 37774
    posted

    The UltraDateTimeEditor uses a .NET MonthCalendar in its dropdown portion, so theoretically it should also provide all the features that the MonthCalendar does.  I didn't see anything exposed that lets you access the MonthlyBoldedDates collection that's on MonthCalendar, though.  What you can do is use reflection to get the calendar used in the dropdown and set those dates yourself, i.e.:

     private void ultraDateTimeEditor1_AfterDropDown(object sender, EventArgs e)
    {
        DateTimeEditor editor = (DateTimeEditor)this.ultraDateTimeEditor1.Editor;
        PropertyInfo info = typeof(DateTimeEditor).GetProperty("MonthDropDown", BindingFlags.NonPublic | BindingFlags.Instance);
        MonthDropDown dd = info.GetValue(editor, null) as MonthDropDown;
        if (dd != null)
            dd.MonthlyBoldedDates = new DateTime[ { DateTime.Now.AddDays(-1) };
    }

    Note that you have to do this in the AfterDropDown because the control disposes the calendar between dropdown operations.  You can use the MonthlyBoldedDates, BoldedDates, or AnnuallyBoldedDates as necessary.

    As for painting different dates different colors, I don't think this is possible with the .NET control, so I don't see any way to do it with the UltraDateTimeEditor either.

    What do you mean about "Can you disable dates after today to pick up"?  If you mean prevent users from selecting any date past today, you could simply set the MaxDate on the control.

    -Matt

Reply Children