Drag drop appointment and open dialog after drop

4 posts, 0 answers
  1. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 14 Mar 2012 Link to this post

    Hi,

    I've been following this example which works great
    :
    http://www.telerik.com/help/winforms/scheduler-appointments-and-dialogs-drag-and-drop-from-another-control.html

    What I would like to do is once I have dropped the appointment I would like the apppointment dialog box to open so I can enter some addtional data. I am also using the CustomEditAppointmentDialog example so I can use my own fields etc.

    Is this possible, I've tried firing the _AppointmentEditDialogShowing event but can't pas the appointment details ie times etc it comes up with a invalid cast.

    Thanks

  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 16 Mar 2012 Link to this post

    Hi Karl,

    Thank you for your question.

    Yes, you can achieve this by calling the ShowAppointmentEditDialog of RadScheduler after you have added the appointment to the Appointments collection. The following code snippet demonstrates how you should modify the radScheduler1_DragDrop method of the mentioned help article in order to achieve the desired behavior:
    private void radScheduler1_DragDrop(object sender, DragEventArgs e)
    {
        Point point = this.radScheduler1.PointToClient(new Point(e.X, e.Y));
     
        DayViewAppointmentsTable table = (this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement).DataAreaElement.Table;
        SchedulerCellElement schedulerCell = SchedulerUIHelper.GetCellAtPoint(point, table.Children);
        if (schedulerCell != null)
        {
            DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
            if (dragObject != null)
            {
                this.radScheduler1.Appointments.BeginUpdate();
                Appointment appointment = CreateAppointment(schedulerCell.Date, dragObject);
                this.radScheduler1.Appointments.Add(appointment);
                this.radScheduler1.Appointments.EndUpdate();
     
                this.radScheduler1.ShowAppointmentEditDialog(appointment, false);
            }
        }
     
        this.mouseDownPosition = Point.Empty;
        this.isDragging = false;
    }

    I hope you find this useful. Do let me know if you have any additional questions.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 16 Mar 2012 Link to this post

    Hi,

    Thanks for the reply, this works to open the dialog but still doesn't allow me to access my custom fields.

    This would work if I doubled click to add an appointment.

    Would I need to do anything else?

    Thanks
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 21 Mar 2012 Link to this post

    Hello Karl,

    The reason might be that you are instantiating the default Appointment type on the DragDrop event where you should instantiate your custom appointment type instead. However, I am not sure if this is the case, because I do not have the source code of your project. Therefore I have prepared a small sample project which implements the desired scenario. I hope you find it useful.

    If you have any further questions, I will be glad to answer them.

    Greetings,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top