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
125
UltraDateTimeEditor - Custom Default Date
posted
I was looking around on google and I could not come up with any solutions for my problem.  Basically what I want is to be able to override or set the datetime value that appears in the calendar dropdown for the Today's Date. Because the system date for our application is not always the same as the current date. Is there a way that I can override or set this date?
Parents
No Data
Reply
  • 37774
    posted

    While there is nothing public that is exposed that would allow you to do this, you could use reflection (assuming that your application will have reflection permissions) to access the underlying .NET MonthCalendar and change the date:

     
            private void ultraDateTimeEditor1_AfterDropDown(object sender, EventArgs e)
            {
                DateTimeEditor editor = (DateTimeEditor)this.ultraDateTimeEditor1.Editor;

                PropertyInfo propInfo = editor.GetType().GetProperty("MonthDropDown", BindingFlags.NonPublic | BindingFlags.Instance);
                MonthCalendar calendar = (MonthCalendar)propInfo.GetValue(editor, null);
                calendar.TodayDate = new DateTime(2009, 1, 1);
            }

    -Matt

Children