Articles in this section

How to add, delete and edit the appointments in WinForms Scheduler?

Appointments in WinForms Scheduler can be managed - added, edited, or deleted - by utilizing a custom appointment form. The custom appointment form is displayed through the ShowingAppointmentForm event. The default appointment form can be suppressed by setting the e.Cancel property, and the custom form can be presented by invoking its ShowDialog method.

Code for showing custom appointment form:

AppointmentForm form;
//Hook the event for showing the appointment form.
this.scheduleControl1.ShowingAppointmentForm += scheduleControl1_ShowingAppointmentForm;

/// <summary>
/// Raise the event when showing the appointment form
/// </summary>
void scheduleControl1_ShowingAppointmentForm(object sender, ShowingAppointFormEventArgs e)
{
   //Cancel the default appointment form for schedule control.
   e.Cancel = true;
   //Shows the Custom appointment form.
   form.ShowDialog();
} 

Code for add or edit an appointment using the custom appointment form:

void OnAddorEditItem_Clicked(object sender, EventArgs e)
{
    IScheduleAppointment item;

    if (isEdit && currentAppointment != null)
    {
        //Update existing
        item = currentAppointment; 
    }
    else
    {
        //New
        item = dataProvider.NewScheduleAppointment(); 
    }

    if (item != null)
    {
        item.AllDay = true;
        item.StartTime = StartDateDateTimePickerAdv.Value;
        item.EndTime = EndDateDateTimePickerAdv.Value;
        item.Subject = SubjectTextBoxExt.Text;
        item.LabelValue = comboBox1.SelectedIndex;

        if (!isEdit)
        {
           dataProvider.AddItem(item);
        }             
    }
    schedulegrid.GetScheduleHost().SetDataToDayPanels();     
    this.Close();
} 

Code for deleting appointment:

void OnDeleteItem_Clicked(object sender, EventArgs e)
{
    //Remove the appointment
    scheduleProvider.RemoveItem(appointment);
    scheduleControl1.GetScheduleHost().SetDataToDayPanels();
} 

Schedule.gif

Take a moment to peruse the WinForms ScheduleControl - Getting Started documentation, where you can find about getting started in ScheduleControl, with code examples.

View sample in GitHub

Conclusion

I hope you enjoyed learning how to add, delete and edit the appointments in WinForms Scheduler.

You can refer to our WinForms Scheduler feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms Schedule Control example to understand how to create and manipulate data.
For current customers, check out our components from the License and Downloads page. If you are new to Syncfusion, try our 30-day free trial to check out our other controls.
Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied