routing or delegating event to AppointmentEditDialogShowing event

5 posts, 0 answers
  1. Noé
    Noé avatar
    13 posts
    Member since:
    Apr 2011

    Posted 12 Jun 2013 Link to this post

    Hello.
    * using C Sharp + WinForms

    I have created a custom menu and when i attach it to Scheduler context menu, i can no longer access the AppointmentEditDialogShowing event.

    What i am trying to do is populate the Start and End dates into my Custom New/Edit Appointment Dialog. If i use the default context menu, on the EditDialogShowing event, i can catch the dates using :

    Telerik.WinControls.UI.Appointment app = (Telerik.WinControls.UI.Appointment)e.Appointment;
    DateTime ini = app.Start;
    DateTime end = app.End;
     
    //cancel Scheduler Edit/new built in dialog
    e.Cancel = true;
     
    //Pass the values to my new/edit dialog and show it
    .....

    If i use my custom context menu, select a few empty cells and no longer know when it starts and ends. What can i do catch this dates using this ex: custom context menu ?

    foreach (RadItem ri in e.ContextMenu.Items)
    {
           ri.Visibility = ElementVisibility.Collapsed;
    }
     
    RadMenuItem rmi1 = new RadMenuItem("New / Edit Special Appointment");
    rmi1.Click += new EventHandler(rmi1_Click);
     
    RadMenuItem rmi2 = new RadMenuItem("Another Action");
    rmi2.Click += new EventHandler(rmi2_Click);
     
     e.ContextMenu.Items.Add(rmi1);
     e.ContextMenu.Items.Add(rmi2);
  2. Noé
    Noé avatar
    13 posts
    Member since:
    Apr 2011

    Posted 13 Jun 2013 Link to this post

    little update.

    while reading a bit a found i could use:
    RadScheduler.CreateNewAppointmentCommand.ExecuteCommand(this.radScheduler1);
    to show the AppointmentEditDialog from a new context menu item i have created, but when i reach the AppointmentEditDialogShowing event and do:

    Telerik.WinControls.UI.Appointment app = (Telerik.WinControls.UI.Appointment)e.Appointment;
    app is null. why ?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 17 Jun 2013 Link to this post

    Hi Noe,

    Thank you for writing.

    I am not sure that I fully understand your scenario by using the provided information. 
    You can get the selected cells in the scheduler as follows:
    List<SchedulerCellElement> cells = SchedulerUIHelper.GetSelectedCells(this.radScheduler1);
    and each cell has a Date property which is the date which that cell is representing.

    At this point the Appointment is not created yet and the purpose of this event is to allow changing the default appointment dialog. For example:
    private void radScheduler_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
    {
        e.AppointmentEditDialog = new MyEditAppointmentDialog();
    }

    In your custom edit appointment dialog, you should override the EditAppointment method and then in this method you will have access to the event.

    I hope you find this useful.

    Regards,
    Peter
    Telerik
    RadChart for WinForms is obsolete. Now what?
  5. Noé
    Noé avatar
    13 posts
    Member since:
    Apr 2011

    Posted 17 Jun 2013 Link to this post

    Hello Peter, thank you for the answer.
    I was able to work with the cells snippet code.

    About overriding the EditAppointment , i don't understand what i have to do. My EditControl does not extend the AppointmentEditDialog. I am not sure if this matters or not.
  6. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 20 Jun 2013 Link to this post

    Hi,

    I am happy that you are able to access the cells.
    Your control should inherit from AppointmentEditDialog. For more information how can do this please read this help article.

    I hope this helps.

    Regards,
    Peter
    Telerik
    RadChart for WinForms is obsolete. Now what?
Back to Top
UI for WinForms is Visual Studio 2017 Ready