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
135
UltraMonthViewSingle
posted

Hi,

I'm trying to change to text on the UltraMonthViewSingle week header. Currently it displays the date range for the week on the left side. I want to display a timeperiod number with this date range. My client have weeks running from Saturday to Friday, each one of these weeks is an incremental number running accross years. E.g. week number 501 is 22 Nov 2008 - 28Nov 2008. I want to show this number on the left with the date range.

Is it possible to do this? 

Regards

  • 69832
    Offline posted

    It is possible, using the IUIElementCreationFilter interface. Note, however, that you might have a problem with the amount of space required to show the date range and the week number. One possible solution for that problem is to use the VisibleWeeks property to reduce the number of weeks shown by the control, thus increasing the vertical space available to each one. The following code sample demonstrates this approach:

    using nsMVS = Infragistics.Win.UltraWinSchedule.MonthViewSingle;

    this.monthViewSingle.VisibleWeeks = 4;
    this.monthViewSingle.WeekHeaderDisplayStyle = WeekHeaderDisplayStyle.DateRange;
    this.monthViewSingle.CreationFilter = new WeekNumberCreationFilter();


    public class WeekNumberCreationFilter : IUIElementCreationFilter
    {

        #region IUIElementCreationFilter Members

        void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent)
        {
            if ( parent is nsMVS.WeekNumberUIElement )
            {
                Week week = parent.GetContext( typeof(Week) ) as Week;
                TextUIElement textElement = parent.GetDescendant( typeof(TextUIElement) ) as TextUIElement;
                if ( textElement != null )
                {
                    string text = string.Format( "{0}-{1} ({2})", week.FirstDate.ToString("MM/dd"), week.LastDate.ToString("MM/dd"), week.WeekNumber );
                    textElement.Text = text;
                    textElement.Rect = parent.RectInsideBorders;
                }
            }
        }

        bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent)
        {
            return  false;
        }

        #endregion IUIElementCreationFilter Members
    }