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

Add new button to the footer

8 Answers 139 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
DoomerDGR8 asked on 08 Feb 2011, 03:46 PM
Hi, I was wondering if I could add a new button to the footer of a RadCalendar?

8 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 Feb 2011, 05:01 PM
Hello Hassan,

A new button can be added as per this exmaple

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.RadCalendar1.ShowFooter = True
    Me.RadCalendar1.CalendarElement.CalendarStatusElement.TodayButton.Visibility = ElementVisibility.Visible
    Me.RadCalendar1.CalendarElement.CalendarStatusElement.ClearButton.Visibility = ElementVisibility.Visible
    Dim button As New RadButtonElement("Hi")
    button.MaxSize = New Size(50, 18)
      
    AddHandler button.Click, AddressOf Button_Click
    Me.RadCalendar1.CalendarElement.CalendarStatusElement.Children(0).Children.Add(button)
End Sub
Private Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
    MessageBox.Show("Hi Hassan")
End Sub

Hope that helps
Richard
0
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
answered on 11 Feb 2011, 05:41 PM
Okay, want to add more buttons now...

This code
private void SetupSpecialCalendarButtons() {
  CalendarDiary.ShowFooter = true;
  CalendarDiary.CalendarElement.CalendarStatusElement.TodayButton.Visibility = ElementVisibility.Visible;
  CalendarDiary.CalendarElement.CalendarStatusElement.ClearButton.Visibility = ElementVisibility.Visible;
 
  RadButtonElement ButtonSpecialCalendar = new RadButtonElement("Available") {
    MaxSize = new Size(150, 18),
    ToolTipText = "Mark Available",
    TextImageRelation = TextImageRelation.ImageBeforeText,
    Image = MenuItemAvailable.Image
  };
  ButtonSpecialCalendar.Click += ButtonSpecialCalendar_MarkAvailable_Click;
  CalendarDiary.CalendarElement.CalendarStatusElement.Children[0].Children.Add(ButtonSpecialCalendar);
 
  ButtonSpecialCalendar = new RadButtonElement("Unavailable") {
    MaxSize = new Size(150, 18),
    ToolTipText = "Mark Unavailable",
    TextImageRelation = TextImageRelation.ImageBeforeText,
    Image = MenuItemUnavailable.Image
  };
  ButtonSpecialCalendar.Click += ButtonSpecialCalendar_MarkUnAvailable_Click;
  CalendarDiary.CalendarElement.CalendarStatusElement.Children[0].Children.Add(ButtonSpecialCalendar);
 
  ButtonSpecialCalendar = new RadButtonElement("Holiday") {
    MaxSize = new Size(150, 18),
    ToolTipText = "Mark Holiday",
    TextImageRelation = TextImageRelation.ImageBeforeText,
    Image = MenuItemHoliday.Image
  };
  ButtonSpecialCalendar.Click += ButtonSpecialCalendar_MarkHoliday_Click;
  CalendarDiary.CalendarElement.CalendarStatusElement.Children[0].Children.Add(ButtonSpecialCalendar);
}

Does this (see attached image)
0
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
answered on 12 Feb 2011, 01:41 PM
Any solution? Thanks.
0
Richard Slade
Top achievements
Rank 2
answered on 12 Feb 2011, 01:51 PM
Hi Hassan,

I thought you were just sharing your new solution with us, What's the issue?
Richard
0
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
answered on 12 Feb 2011, 03:10 PM
Need to show more buttons. please see attached screenshot above.
0
Richard Slade
Top achievements
Rank 2
answered on 13 Feb 2011, 01:22 AM
HI Hassan,

I think that this will involve adding a RadPanelElement to the DockLayoutPanel in the CalendarStatusElement and then adding the buttons to the RadPanelElement. I'll see if I can work something out for you and and get back to you as soon as I can .
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 13 Feb 2011, 01:38 AM
One quick way may be to collapse the label element that shows the current date time.
radCalendar1.CalendarElement.CalendarStatusElement.Children[0].Children[2].Visibility = ElementVisibility.Collapsed;
thus giving more room for your buttons
Richard...
0
Ivan Todorov
Telerik team
answered on 16 Feb 2011, 01:40 PM
Hi Hassan,

I think the problem is that you could not dock your buttons to the right. Here is how one should dock element inside a DockLayoutPanel:
myElement.SetValue(Telerik.WinControls.Layouts.DockLayoutPanel.DockProperty,
                Telerik.WinControls.Layouts.Dock.Right);

I have modified your code to make the buttons dock in a proper way:
private void SetupSpecialCalendarButtons()
{
    CalendarDiary.ShowFooter = true;
    CalendarDiary.CalendarElement.CalendarStatusElement.TodayButton.Visibility = ElementVisibility.Visible;
    CalendarDiary.CalendarElement.CalendarStatusElement.ClearButton.Visibility = ElementVisibility.Visible;
 
    RadButtonElement ButtonSpecialCalendar = new RadButtonElement("Available")
    {
        MaxSize = new Size(150, 18),
        ToolTipText = "Mark Available",
        TextImageRelation = TextImageRelation.ImageBeforeText,
        Alignment = ContentAlignment.MiddleRight
    };
    ButtonSpecialCalendar.SetValue(Telerik.WinControls.Layouts.DockLayoutPanel.DockProperty,
        Telerik.WinControls.Layouts.Dock.Right);
    CalendarDiary.CalendarElement.CalendarStatusElement.Children[0].Children.Add(ButtonSpecialCalendar);
 
    ButtonSpecialCalendar = new RadButtonElement("Unavailable")
    {
        MaxSize = new Size(150, 18),
        ToolTipText = "Mark Unavailable",
        TextImageRelation = TextImageRelation.ImageBeforeText,
        Alignment = ContentAlignment.MiddleRight
    };
    ButtonSpecialCalendar.SetValue(Telerik.WinControls.Layouts.DockLayoutPanel.DockProperty,
        Telerik.WinControls.Layouts.Dock.Right);
    CalendarDiary.CalendarElement.CalendarStatusElement.Children[0].Children.Add(ButtonSpecialCalendar);
      
    ButtonSpecialCalendar = new RadButtonElement("Unavailable")
    {
        MaxSize = new Size(150, 18),
        ToolTipText = "Mark Unavailable",
        TextImageRelation = TextImageRelation.ImageBeforeText,
        Alignment = ContentAlignment.MiddleRight
    };
    ButtonSpecialCalendar.SetValue(Telerik.WinControls.Layouts.DockLayoutPanel.DockProperty,
        Telerik.WinControls.Layouts.Dock.Right);
    CalendarDiary.CalendarElement.CalendarStatusElement.Children[0].Children.Add(ButtonSpecialCalendar);
      
}

You may also want to collapse the label element as Richard suggested in the previous post.

Let us know if this helped you. If you have any further questions, do not hesitate to ask.

Greetings,
Ivan Todorov
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Richard Slade
Top achievements
Rank 2
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
Ivan Todorov
Telerik team
Share this question
or