2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Custom appointment formThe 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
Note: 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!
|
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
When displaying the form I have the object ShowingAppointFormEventArgs with the item but I don't know how to add new fields.
In form.cs:
void scheduleControl1_ShowingAppointmentForm(object sender, ShowingAppointFormEventArgs e)
{
//Cancel the default appointform for schedule control
e.Cancel = true;
//Shows the Custom appointment form
form.appointEvent = e;
form.ShowDialog();
}
In AppointmentForm.cs
void AppointmentForm_Load(object sender, System.EventArgs e)
{
colorOptions = new List<string>();
colorOptions.Add("None");
colorOptions.Add("Important");
colorOptions.Add("Business");
colorOptions.Add("Personal");
colorOptions.Add("Vacation");
colorOptions.Add("Must Attend");
colorOptions.Add("Travel Required");
colorOptions.Add("Needs Preparation");
colorOptions.Add("Birthday");
colorOptions.Add("Anniversary");
colorOptions.Add("Phone Call");
this.comboBox1.DataSource = colorOptions;
this.comboBox1.SelectedIndex = this.appointEvent.Item.LabelValue ;
if (this.appointEvent.Item.UniqueID != -1)
{
//Should I retrive here my custom fields?
}
this.StartDateDateTimePickerAdv.Value = this.appointEvent.Item.StartTime;
this.EndDateDateTimePickerAdv.Value = this.appointEvent.Item.EndTime;
this.SubjectTextBoxExt.Text = this.appointEvent.Item.Subject;
}
Hi Felix,
Thanks for using Syncfusion products.
You can add or retrieve a custom field by accessing the specific controls in a form or specifying the item value for the appointment form throw the ShowingAppointFormEventArgs.Item. Please make use of the below code,
Code Example
void AppointmentForm_Load(object sender, System.EventArgs e)
{
colorOptions = new List<string>();
colorOptions.Add("None");
colorOptions.Add("Important");
colorOptions.Add("Business");
colorOptions.Add("Personal");
colorOptions.Add("Vacation");
colorOptions.Add("Must Attend");
colorOptions.Add("Travel Required");
colorOptions.Add("Needs Preparation");
colorOptions.Add("Birthday");
colorOptions.Add("Anniversary");
colorOptions.Add("Phone Call");
this.comboBox1.DataSource = colorOptions;
if (this.AppointmentEvents.Item.UniqueID != -1)
{
this.comboBox1.SelectedIndex = this.AppointmentEvents.Item.LabelValue;
this.SubjectTextBoxExt.Text = this.AppointmentEvents.Item.Subject;
this.StartDateDateTimePickerAdv.Value = this.AppointmentEvents.Item.StartTime;
this.EndDateDateTimePickerAdv.Value = this.AppointmentEvents.Item.EndTime;
this.StartTimeDateTimePickerAdv.Value = this.AppointmentEvents.Item.StartTime;
this.EndTimeDateTimePickerAdv.Value = this.AppointmentEvents.Item.EndTime;
}
else
{
this.comboBox1.SelectedIndex = 0;
this.SubjectTextBoxExt.Text = "New subject";
this.StartDateDateTimePickerAdv.Value = this.AppointmentEvents.Item.StartTime;
this.EndDateDateTimePickerAdv.Value = this.AppointmentEvents.Item.EndTime;
this.StartTimeDateTimePickerAdv.Value = this.AppointmentEvents.Item.StartTime;
this.EndTimeDateTimePickerAdv.Value = this.AppointmentEvents.Item.EndTime;
}
}
The above code sets the new subject if the appointment is not set and if the appointment is set, then it will be retrieved.
If the above solution doesn’t meet your scenario, please create a new support incident using your Direct-Trac login,
https://www.syncfusion.com/account/login
Regards,
Amal Raj U.
Your answer is correct, but if I need to add a new field that is not in this.AppointmentEvents.Item I don't know how to proceed. For example if I want to have a custom form with a field for the department.
Thanks in advance,
Then in :
- In the SimpleScheduleDataProvider class
Public Overrides Function NewScheduleAppointment () AscheduleAppointment
Return New My_CustomAppointment ()
End Function
- In the AppointmentForm Class
Private Sub AppointmentForm_Load (ByVal sender As Object, ByVal and As
System.EventArgs) Handles MyBase.Load
...
Dim appAs Cls_My_CustomAppointment = CType (Me.appointEvent.Item, My_CustomAppointment)
Me.DeparmentTextBoxExt.Text = app.department
...
End Sub