This is a migrated thread and some comments may be shown as answers.

Adding Controls to the Header Element in the Scheduler

1 Answer 84 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Nechama
Top achievements
Rank 1
Nechama asked on 14 Jun 2019, 02:51 PM

Hi,

 

Is it possible to add a series of check boxes to each header? I would like them to appear directly underneath the date.

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 19 Jun 2019, 02:12 PM
Hello, Nechama,

According to the provided information, I suppose that you want to customize the default DayViewHeader element and add some check boxes underneath the date. The easiest way to achieve this is to use SchedulerElementProvider class which allows to replace the default RadScheduler element with custom ones. Please, refer to the following article for further information: https://docs.telerik.com/devtools/winforms/controls/scheduler/fundamentals/scheduler-element-provider-

You need to create SchedulerElementProvider descendant class and override the CreateElement method, as shown in the following code snippet:
public Form1()
{
    InitializeComponent();
 
    this.radScheduler1.ElementProvider = new MyElementProvider(this.radScheduler1);
    SchedulerDayViewElement dayViewElement = (SchedulerDayViewElement)this.radScheduler1.ViewElement;
    dayViewElement.HeaderElement.HeaderHeight = 50;
}
 
public class MyElementProvider : SchedulerElementProvider
{
    public MyElementProvider(RadScheduler scheduler)
        : base(scheduler)
    {
    }
    protected override T CreateElement<T>(SchedulerView view, object context)
    {
         
        if (typeof(T) == typeof(SchedulerHeaderCellElement))
        {
            return new CustomSchedulerHeaderCellElement(this.Scheduler, view) as T;
        }
        return base.CreateElement<T>(view, context);
    }
}

 After that you need to create your custom element which should be inherit of the SchedulerHeaderCellElement class and override some of its the default properties and methods. Indeed, you can create a stack layout element which will contains the date and the check boxes in itself. Please refer to the following code snippet which demonstrates how to achieve the illustrated result:


public class CustomSchedulerHeaderCellElement : SchedulerHeaderCellElement
{
    public CustomSchedulerHeaderCellElement(RadScheduler scheduler, SchedulerView view) : base(scheduler, view)
    {
    }
 
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(SchedulerHeaderCellElement);
        }
    }
 
    StackLayoutElement horizontalPanel = new StackLayoutElement();
    StackLayoutElement vertualPanel = new StackLayoutElement();
    LightVisualElement date = new LightVisualElement();
    RadCheckBoxElement checkBox1 = new RadCheckBoxElement();
    RadCheckBoxElement checkBox2 = new RadCheckBoxElement();
    RadCheckBoxElement checkBox3 = new RadCheckBoxElement();
 
    protected override void CreateChildElements()
    {
        base.CreateChildElements();
 
        date.StretchHorizontally = true;
 
        vertualPanel.Orientation = Orientation.Vertical;
        vertualPanel.StretchHorizontally = true;
        horizontalPanel.Orientation = Orientation.Horizontal;
        horizontalPanel.StretchHorizontally = true;
 
        horizontalPanel.Children.Add(this.checkBox1);
        horizontalPanel.Children.Add(this.checkBox2);
        horizontalPanel.Children.Add(this.checkBox3);
        checkBox1.CheckStateChanged += CheckBox_CheckStateChanged;
        checkBox2.CheckStateChanged += CheckBox_CheckStateChanged;
        checkBox3.CheckStateChanged += CheckBox_CheckStateChanged;
 
        vertualPanel.Children.Add(date);
        vertualPanel.Children.Add(horizontalPanel);
        this.Children.Add(vertualPanel);
        this.horizontalPanel.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
    }
 
    private void CheckBox_CheckStateChanged(object sender, EventArgs e)
    {
        //TODO
    }
 
    public override string Text
    {
        get { return base.Text; }
        set {
            base.Text = value;
            this.date.Text = value;
            this.DrawText = false;
            if (value == "Local" )
            {
                this.horizontalPanel.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
            }
            else
            {
                this.horizontalPanel.Visibility = Telerik.WinControls.ElementVisibility.Visible;
            }
        }
    }
 
    protected override void InitializeFields()
    {
        base.InitializeFields();
      
    }
}

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Nadya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Scheduler and Reminder
Asked by
Nechama
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or