Add new button to the footer

9 posts, 1 answers
  1. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 08 Feb 2011 Link to this post

    Hi, I was wondering if I could add a new button to the footer of a RadCalendar?
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Feb 2011 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 11 Feb 2011 Link to this post

    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)
  5. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 12 Feb 2011 Link to this post

    Any solution? Thanks.
  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 12 Feb 2011 Link to this post

    Hi Hassan,

    I thought you were just sharing your new solution with us, What's the issue?
    Richard
  7. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 12 Feb 2011 Link to this post

    Need to show more buttons. please see attached screenshot above.
  8. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 12 Feb 2011 Link to this post

    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
  9. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 12 Feb 2011 Link to this post

    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...
  10. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 16 Feb 2011 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready