Setting the weekday format in Scheduler month view

4 posts, 0 answers
  1. Grant
    Grant avatar
    9 posts
    Member since:
    Apr 2015

    Posted 25 Jun 2015 Link to this post

    I am not able to set the weekday format in Scheduler for month view. I am using the control in a very small area, and I need to set the weekday names to be abbreviated (Mon, Tue, Wed, etc.).

    I have set the HeaderFormat property on both the GetMonthView() and the scheduler control, and it does not seem to change. I still see the weekday names fully spelled out, and Wednesday will not fit into the allocated area.

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 30 Jun 2015 Link to this post

    Hello Grant,

    Thank you for writing.

    In order to achieve your goal, it is suitable to use the CellFormatting event and assign the desired string to the respective header cells:
    public Form1()
    {
        InitializeComponent();
        this.radScheduler1.CellFormatting+=radScheduler1_CellFormatting;
        this.radScheduler1.ActiveViewType = Telerik.WinControls.UI.SchedulerViewType.Month;
         
    }
     
    private void radScheduler1_CellFormatting(object sender, Telerik.WinControls.UI.SchedulerCellEventArgs e)
    {
        SchedulerHeaderCellElement headerCell = e.CellElement as SchedulerHeaderCellElement;
        if (headerCell!=null)
        {
            string pattern = headerCell.Date.DayOfWeek.ToString().Substring(0, 3);
            if (headerCell.Text.Length!=pattern.Length&&headerCell.Text.StartsWith(pattern))
            {
                headerCell.Text = pattern;
            }
        }
    }

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Grant
    Grant avatar
    9 posts
    Member since:
    Apr 2015

    Posted 30 Jun 2015 in reply to Dess Link to this post

    This didn't quite work for me, but it set me on the right track. My header cells don't seem to have a valid Date property. All of them seem to be 1/1/1980, which happens to be a Tuesday, so Tuesday gets set correctly to Tue. I am not using a navigator, I don't know if this makes a difference.

    Anyhow, your basic idea did work with a slight modification:

    private void rsReserve_CellFormatting(object sender, SchedulerCellEventArgs e)
    {
    SchedulerHeaderCellElement headerCell = e.CellElement as SchedulerHeaderCellElement;
    if (headerCell != null && headerCell.Text.EndsWith("day"))
    {
    headerCell.Text = headerCell.Text.Substring(0, 3);
    }
    }

     

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 03 Jul 2015 Link to this post

    Hello Grant,

    Thank you for writing back.

    I have attached my sample project as well. Feel free to use this approach which suits your requirement best.

    I hope this information helps. If you have any additional questions, please let me know.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top