Disable and highlight days in timeline view

2 posts, 0 answers
  1. Karl
    Karl avatar
    172 posts
    Member since:
    Sep 2010

    Posted 14 Jun 2012 Link to this post

    I'm writing a booking system and am using the Winforms Scheduler control. Based on data provided from the database for each resource, I need to be able to disable and change the display certain days.

    For instance, if a consultant (resource row in the Schedule) cannot work on a specific day, then this day for that consultant should be visibly shown to be unavailable (highlighted/dimmed/greyed-out) and any clicking in the day cell for that resource should not trigger any events (new/edit appointmnent, and no context menu)

    Can this be done, and if so, how?


  2. Ivan Todorov
    Ivan Todorov avatar
    688 posts

    Posted 18 Jun 2012 Link to this post

    Hi Karl,

    Thank you for contacting us.

    You can use the CellFormatting event to modify the Enabled property corresponding to a specified condition. The following code snippet demonstrates how to achieve this:
         Color[] colors = new Color[]{Color.LightBlue, Color.LightGreen, Color.LightYellow,
    Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue};
         string[] names = new string[]{"Alan Smith", "Anne Dodsworth",
    "Boyan Mastoni", "Richard Duncan", "Maria Shnaider"};
         public Form82()
             for (int i = 0; i < names.Length; i++)
                 Resource resource = new Resource();
                 resource.Id = new EventId(i);
                 resource.Name = names[i];
                 resource.Color = colors[i];
             this.radScheduler1.CellFormatting += new EventHandler<Telerik.WinControls.UI.SchedulerCellEventArgs>(radScheduler1_CellFormatting);
             this.radScheduler1.GroupType = GroupType.Resource;
         void radScheduler1_CellFormatting(object sender, Telerik.WinControls.UI.SchedulerCellEventArgs e)
             if (e.CellElement is SchedulerHeaderCellElement) return;
             IResource res = e.CellElement.View.GetResources() != null ? e.CellElement.View.GetResources()[0] : null;
             DateTime date = e.CellElement.Date;
             if (res != null && !IsAvailable(res, date))
                 e.CellElement.Enabled = false;
                 e.CellElement.Enabled = true;
         private bool IsAvailable(IResource res, DateTime date)
             return date.Day % 2 == 0;

    I hope this will help you. Do not hesitate to write back if you have any further questions.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. DevCraft banner
Back to Top