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

Appointment Layout

10 Answers 243 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Frederico Fernandes
Top achievements
Rank 1
Frederico Fernandes asked on 14 Nov 2011, 06:17 PM
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.

10 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 17 Nov 2011, 03:33 PM
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.

0
Frederico Fernandes
Top achievements
Rank 1
answered on 06 Dec 2011, 10:34 AM
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.
0
Accepted
Ivan Todorov
Telerik team
answered on 08 Dec 2011, 10:37 AM
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.

0
Frederico Fernandes
Top achievements
Rank 1
answered on 04 Jan 2012, 06:47 PM
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?

0
Ivan Todorov
Telerik team
answered on 06 Jan 2012, 05:06 PM
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).
0
Karl
Top achievements
Rank 1
answered on 19 Jan 2012, 12:15 PM
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

 

0
Ivan Todorov
Telerik team
answered on 24 Jan 2012, 09:46 AM
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).

0
Karl
Top achievements
Rank 1
answered on 25 Jan 2012, 09:58 AM
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
0
Ivan Todorov
Telerik team
answered on 27 Jan 2012, 02:16 PM
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).

0
Karl
Top achievements
Rank 1
answered on 27 Jan 2012, 04:44 PM
Thanks, that works.
Tags
Scheduler and Reminder
Asked by
Frederico Fernandes
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Frederico Fernandes
Top achievements
Rank 1
Karl
Top achievements
Rank 1
Share this question
or