Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Scheduler and Reminder > Appointment Layout

Answered Appointment Layout

Feed from this thread
  • Frederico Fernandes avatar

    Posted on Nov 14, 2011 (permalink)

    Hi,

    Is it possible to change appointment layout?
    In RadScheduler control for asp.net we can customize appointment template and i want to do the same in RadScheduler for Windows Forms. What i want to do is something like the appearance in image attached. The round rectangle named "report" is a clickable button.
    Attached files

    Reply

  • Ivan Todorov Ivan Todorov admin's avatar

    Posted on Nov 17, 2011 (permalink)

    Hi Frederico Fernandes,

    Thank you for contacting us.

    Although the architecture of the WinForms components is fairly different than the the architecture of the ASP.NET AJAX ones, it is still possible to add a button to the appointments by using the AppointmentFormatting event as it is shown in the next snippet:

    this.radScheduler1.AppointmentFormatting += new EventHandler<SchedulerAppointmentEventArgs>(radScheduler1_AppointmentFormatting);
     
    void radScheduler1_AppointmentFormatting(object sender, SchedulerAppointmentEventArgs e)
    {
        if (e.AppointmentElement.Children.Count > 0)
        {
            return;
        }
     
        RadButtonElement button = new RadButtonElement();
        button.Text = "Report";
        button.Tag = e.Appointment;
        button.StretchHorizontally = button.StretchVertically = false;
        button.Alignment = ContentAlignment.BottomRight;
        button.Click +=new EventHandler(button_Click);
        e.AppointmentElement.Children.Add(button);
    }
     
    void button_Click(object sender, EventArgs e)
    {
        RadButtonElement senderButton = sender as RadButtonElement;
        if (sender == null)
        {
            return;
        }
     
        Appointment app = senderButton.Tag as Appointment;
        if (app == null || !this.radScheduler1.Appointments.Contains(app))
        {
            return;
        }
     
        RadMessageBox.Show("Report :" + app.Summary);
    }

    I hope you find this useful. If you have any additional questions, feel free to write us back. All the best,
    Ivan Todorov
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

    Reply

  • Frederico Fernandes avatar

    Posted on Dec 6, 2011 (permalink)

    Hello Ivan,

    Thanks that is what i really want.

    If i want to put more than one button how i change your code to put buttons aligned in bottom right without overlap each other.

    Reply

  • Answer Ivan Todorov Ivan Todorov admin's avatar

    Posted on Dec 8, 2011 (permalink)

    Hi Frederico,

    The best approach to put a second button beside the first one, is to use a StackLayoutPanel as the following code snippet demonstrates:
    void radScheduler1_AppointmentFormatting(object sender, SchedulerAppointmentEventArgs e)
    {
        if (e.AppointmentElement.Children.Count > 0)
        {
            return;
        }
     
        RadButtonElement button = new RadButtonElement();
        button.Text = "Report";
        button.Tag = e.Appointment;
        button.StretchHorizontally = button.StretchVertically = false;
        button.Alignment = ContentAlignment.BottomRight;
        button.Click += new EventHandler(button_Click);
     
        RadButtonElement button2 = new RadButtonElement();
        button2.Text = "Report2";
        button2.Tag = e.Appointment;
        button2.StretchHorizontally = button2.StretchVertically = false;
        button2.Alignment = ContentAlignment.BottomRight;
        button2.Click += new EventHandler(button_Click);
     
        StackLayoutPanel stack = new StackLayoutPanel();
        stack.Orientation = Orientation.Horizontal;
        stack.StretchHorizontally = stack.StretchVertically = false;
        stack.Alignment = ContentAlignment.BottomRight;
        stack.Children.Add(button);
        stack.Children.Add(button2);
     
        e.AppointmentElement.Children.Add(stack);
    }

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

    Greetings,
    Ivan Todorov
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

    Reply

  • Frederico Fernandes avatar

    Posted on Jan 4, 2012 (permalink)

    Hi Ivan,

    There is a problem in your code. When i change view, buttons disappear. Do you know why that happens and how can i solve it?

    Reply

  • Ivan Todorov Ivan Todorov admin's avatar

    Posted on Jan 6, 2012 (permalink)

    Hello Frederico,

    Thank you for writing back.

    This appears to be a layout issue in the AppointmentElement which is present when it has only one child element added (in the current case this is the StackLayoutPanel). I have logged it to PITS and we will address it in a future release. Here is the link to the PITS item. To workaround this issue, you just need to add a second empty child to the AppointmentElement:
    void radScheduler1_AppointmentFormatting(object sender, SchedulerAppointmentEventArgs e)
    {
        if (e.AppointmentElement.Children.Count > 0)
        {
            return;
        }
     
        RadButtonElement button = new RadButtonElement();
        button.Text = "Report";
        button.Tag = e.Appointment;
        button.StretchHorizontally = button.StretchVertically = false;
        button.Alignment = ContentAlignment.BottomRight;
        button.Click += new EventHandler(button_Click);
     
        RadButtonElement button2 = new RadButtonElement();
        button2.Text = "Report2";
        button2.Tag = e.Appointment;
        button2.StretchHorizontally = button2.StretchVertically = false;
        button2.Alignment = ContentAlignment.BottomRight;
        button2.Click += new EventHandler(button_Click);
     
        StackLayoutPanel stack = new StackLayoutPanel();
        stack.Orientation = Orientation.Horizontal;
        stack.StretchHorizontally = stack.StretchVertically = false;
        stack.Alignment = ContentAlignment.BottomRight;
        stack.Children.Add(button);
        stack.Children.Add(button2);
     
        e.AppointmentElement.Children.Add(stack);
        e.AppointmentElement.Children.Add(new StackLayoutPanel());
    }

    Your Telerik points have been updated for bringing this issue to our attention. Should you have any future questions, do not hesitate to contact us.

    All the best,
    Ivan Todorov
    the Telerik team

    SP1
    of Q3’11 of RadControls for WinForms is available for download (see what's new).

    Reply

  • Karl Master avatar

    Posted on Jan 19, 2012 (permalink)

    Hi,

    Is there any way of accessing the mappings in this event:
    This is one of my mappings:

    appointmentMappingInfo.Mappings.Add(

     

    new SchedulerMapping("test1", "test1"));

    I would like to add some logic and change the appointment.Summary.

    Thanks

     

    Reply

  • Ivan Todorov Ivan Todorov admin's avatar

    Posted on Jan 24, 2012 (permalink)

    Hello Karl,

    Thank you for your question.

    Yes, you can always access the mapping by using the following code:

    this.radScheduler1.DataSource.GetEventProvider().Mapping.FindByDataSourceProperty("test1");

    However, I am not sure if this will help you in achieving your scenario since the mapping itself cannot help you get the value of this property. Instead, you might find the Appointment property and its DataBoundItem property more appropriate:

    void radScheduler1_AppointmentFormatting(object sender, SchedulerAppointmentEventArgs e)
    {
        e.AppointmentElement.Text = e.Appointment.Summary + " " + e.Appointment.Location;
      
        //OR
     
        if(e.Appointment.DataItem != null)
            e.AppointmentElement.Text = ((YourBoundObjectType)e.Appointment.DataItem).YourDesiredProperty; 
    }

    I hope you find this information useful. If you have any additional questions, I will be glad to answer them.

    Greetings,
    Ivan Todorov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

    Reply

  • Karl Master avatar

    Posted on Jan 25, 2012 (permalink)

    Hi,

    Thanks for replay. I've tried your second suggestion:
    void radScheduler1_AppointmentFormatting(object sender, SchedulerAppointmentEventArgs e)
    {
        e.AppointmentElement.Text = e.Appointment.Summary + " " + e.Appointment.Location;
        
        //OR
       
        if(e.Appointment.DataItem != null)
            e.AppointmentElement.Text = ((YourBoundObjectType)e.Appointment.DataItem).YourDesiredProperty;  
    }
    Where you mention YourBoundObjectType I'm following the "OutlookLikeAppointment" example "CustomEditAppointmentDialog", I added this and get Unable to cast object of type 'System.Data.DataRowView' to type 'OutlookLikeAppointment'. Am I mmissing something?

    Thanks

    Reply

  • Ivan Todorov Ivan Todorov admin's avatar

    Posted on Jan 27, 2012 (permalink)

    Hi Karl,

    e.Appointment.DataItem will give you access to the bound object of the appointment (e.g. if you have RadScheduler bound to a DataTable it will be of type DataRowView). To access the logical Appointment object of the currently being formatted AppointmentElement you need only the e.Appointment property.

    In the case of the Custom Edit Appointment Dialog example, the appointments are of type OutlookLikeAppointment but since the scheduler is bound to a data table, the objects which the appointments are bound to, are of type DataRowView.

    In other words, this means that if you would like to access the database record of the current appointment, you need to use:
    ((DataRowView)e.Appointment.DataItem)["ColumnName"];

    and if you want to access the appointment itself, you can use:
    ((OutlookLikeAppointment)e.Appointment).Email;

    I hope you find this information useful.

    All the best,
    Ivan Todorov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

    Reply

  • Karl Master avatar

    Posted on Jan 27, 2012 (permalink)

    Thanks, that works.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Scheduler and Reminder > Appointment Layout
Related resources for "Appointment Layout"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]