How to add the appointments using custom appointment form in WinForms ScheduleControl?
Custom appointment form
The custom appointment form in WinForms Scheduler can be shown by using the ShowingAppointmentForm event. The default appointment form can be canceled by using the e.Cancel property and custom appointment can be shown by calling its ShowDialog method.
C#
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(); }
VB
Private form As AppointmentForm 'Hook the event for showing the appointment. Private Me.scheduleControl1.ShowingAppointmentForm += AddressOf scheduleControl1_ShowingAppointmentForm ''' <summary> ''' Raise the event when showing the appointment form ''' </summary> Private Sub scheduleControl1_ShowingAppointmentForm(ByVal sender As Object, ByVal e As ShowingAppointFormEventArgs) 'Cancel the default appointment form for schedule control. e.Cancel = True ' Shows the Custom appointment form. form.ShowDialog() End Sub
The appointment can be added to the schedule control from custom appointment form.
C#
void ok_Click(object sender, System.EventArgs e) { //Create a new schedule appointment IScheduleAppointment item = provider.NewScheduleAppointment(); if (item != null) { item.AllDay = true; item.StartTime = this.StartDateDateTimePickerAdv.Value; item.EndTime = this.EndDateDateTimePickerAdv.Value; item.Subject = this.SubjectTextBoxExt.Text; item.LabelValue = this.comboBox1.SelectedIndex; //Appointment can be added in ScheduleDataProvider provider.AddItem(item); } this.schedulegrid.DataSource = provider; this.schedulegrid.GetScheduleHost().SetDataToDayPanels(); this.Close(); }
VB
Private Sub ok_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'Create a new schedule appointment Dim item As IScheduleAppointment = provider.NewScheduleAppointment() If item IsNot Nothing Then item.AllDay = True item.StartTime = Me.StartDateDateTimePickerAdv.Value item.EndTime = Me.EndDateDateTimePickerAdv.Value item.Subject = Me.SubjectTextBoxExt.Text item.LabelValue = Me.comboBox1.SelectedIndex 'Appointment can be added in ScheduleDataProvider provider.AddItem(item) End If Me.schedulegrid.DataSource = provider Me.schedulegrid.GetScheduleHost().SetDataToDayPanels() Me.Close() End Sub
Screenshot
Samples:
Conclusion
I hope you enjoyed learning about how to add the appointments using custom appointment form in WinForms ScheduleControl.
You can refer to our WinForms Scheduler’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Scheduler documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms Scheduler and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!