We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to add the appointments using custom appointment form?

The custom appointment form 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.

 

Code snippet

 

C#

 

VB

 

Note

The appointment can be added to the schedule control from custom appointment form through following code,

C#

 

VB

 

Screenshot

 

Sample Links

C#: Custom AppointmentForm

VB: Custom AppointmentForm

Article ID: Published Date: Last Revised Date: Platform: Control:
7105 09/25/2016 09/25/2016 Windows Forms ScheduleControl
Tags:
Did you find this information helpful?
Comments
Felix Bagur Nov 29, 2016
Thanks for this example. If you could please tell me how to add and retrieve a custom field in the form would be great.
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();
            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;
        }

Reply
Amal Raj Umapathy Selvam [Syncfusion] Dec 01, 2016

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.

Reply
Felix Bagur Dec 01, 2016
Thank you very much for answering

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,
Reply
Felix Bagur Dec 01, 2016
I have found a solution,  create a class My_CustomAppointment that inherits from ScheduleAppointment where I add the new properties for the appointment.

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
Reply
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.