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
230
Monthly View for the Current Year only
posted

Hi,

I am trying to create a monthly view using ultramonthviewmulti control. But I am not able to display the months only for the current year. The months appear in a rolling 12 months fashion from the current month. (see image attached)

I have tried the below code to set min and max date, but it doesn't help. I am using the Infragistics 7.3 as of now. Any help is much appriciated.

=========================================================================== 

          //    Get the current year
           int currentYear = DateTime.Today.Date.Year;

           //    Get the number of months in the year for the current culture's calendar
           int numberOfMonthsInYear = System.Globalization.CultureInfo.CurrentCulture.Calendar.GetMonthsInYear( currentYear );

           //    Get the number of days in the last month of the year
           Infragistics.Win.UltraWinSchedule.Month month = this.ultraCalendarInfo1.GetMonth( numberOfMonthsInYear, currentYear );
           int numberOfDaysInMonth = month.DaysInMonth;
          
           //    Set the MinDate property to the first day of the current year
           this.ultraCalendarInfo1.MinDate = new DateTime( currentYear, 1, 1 );

           //    Set the MaxDate property to the last day of the current year
           this.ultraCalendarInfo1.MaxDate = new DateTime( currentYear, numberOfMonthsInYear, numberOfDaysInMonth );

  • 230
    Suggested Answer
    posted

    I got it working. The below code did the trick. Found it on another forum question.

    this.ultraMonthViewMulti1.FirstMonth = this.ultraMonthViewMulti1.CalendarInfo.GetMonth(1, DateTime.Today.Year);

    Thanks anyways.