Appointment canceled

3 posts, 1 answers
  1. Dominik
    Dominik avatar
    59 posts
    Member since:
    Dec 2012

    Posted 31 Dec 2012 Link to this post

    Hi,

    From my main form (where scheduler is), I am trying to add new appointment and show edit form like this:

    IEvent newAppointment = new CustomAppointment();
    newAppointment.Start = Record.RecordStart;
    newAppointment.End = DateTime.Now;
    // ...
     
    cScheduler.Appointments.Add(newAppointment);
    cScheduler.ShowAppointmentEditDialog(newAppointment, false);

    The problem is when user click cancel or close button in edit form. After that appointment will be still in collection.
    How to check if user cancel appointment and delete it form collection? 



  2. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 03 Jan 2013 Link to this post

    Hi Dominik,

    Thank you for your question.

    The ShowAppointmentEditDialog method returns the DialogResult of the dialog so you can check it. The following code demonstrates how you can add the new appointment only if the OK button was clicked:
    private void radButton1_Click(object sender, EventArgs e)
    {
        IEvent newAppointment = new Appointment();
        newAppointment.Start = DateTime.Now.AddHours(-1);
        newAppointment.End = DateTime.Now;
        // ...
         
        if(cScheduler.ShowAppointmentEditDialog(newAppointment, false) == System.Windows.Forms.DialogResult.OK)
        {
            cScheduler.Appointments.Add(newAppointment);
        }
    }

    I hope you find this useful. Feel free to ask if you have any additional questions.

    Kind regards,
    Ivan Todorov
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dominik
    Dominik avatar
    59 posts
    Member since:
    Dec 2012

    Posted 03 Jan 2013 Link to this post

    Yep that will work fine.
    Thank you very much!

Back to Top