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

Button to add Appointment with Custom AppointmentEditForm - Event

1 Answer 75 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Yanick
Top achievements
Rank 1
Yanick asked on 04 Mar 2019, 03:35 AM

Hi,

I have created a custom appointment edit form. In my main form I added a button to add new appointment to the scheduler.

private void btnAddMessage_Click(object sender, EventArgs e)
       {
 
           if (radScheduler.SelectionBehavior.HasCellsSelected)
           {
               radScheduler.Appointments.Add(new AppointmentATC(radScheduler.SelectionBehavior.GetSelectedInterval().Start, radScheduler.SelectionBehavior.GetSelectedInterval().Duration));
               radScheduler.ShowAppointmentEditDialog(radScheduler.Appointments[radScheduler.Appointments.Count - 1], false);
           }
           else
           {
               radScheduler.Appointments.Add(new AppointmentATC(DateTime.Now, TimeSpan.FromHours(0.5)));
               radScheduler.ShowAppointmentEditDialog(radScheduler.Appointments[radScheduler.Appointments.Count - 1], false);
           }
       }

 

When I click the button everything work fine.

 

The problem is :

When I click OK button the event AppointmentAdded was not trigger. But when I double click cell in scheduler or when I use the context menu to add appointment with my custom form when I click the OK the event AppointmentAdded is Triggered.

How can I add a button to add an appointment and when I click OK button on the EditAppointment form the event AppointmentAdded is triggered.

 

Thank you!

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Mar 2019, 09:34 AM
Hello, Yanick,         

When you call the ShowAppointmentEditDialog method, it requires passing an IEvent instance and a boolean value indicating whether it is a recurring appointment or not. If you pass an existing appointment, it is normal that the AppointmentAdded event won't be fired because you actually don't create a new appointment, but edit an existing one. 

However, the proper API for creating a new appointment via showing the edit dialog is to use the RadScheduler.AddNewAppointmentWithDialog:
private void radButton1_Click(object sender, EventArgs e)
{
    if (radScheduler1.SelectionBehavior.HasCellsSelected)
    {
        this.radScheduler1.AddNewAppointmentWithDialog(radScheduler1.SelectionBehavior.GetSelectedInterval(), false, this.radScheduler1.Resources);
    }
    else
    {
        radScheduler1.Appointments.Add(new Appointment(DateTime.Now, TimeSpan.FromHours(0.5)));
        radScheduler1.ShowAppointmentEditDialog(radScheduler1.Appointments[radScheduler1.Appointments.Count - 1], false);
    }
}

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

Regards,
Dess | Tech Support Engineer, Sr.
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
Yanick
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or