Cancel Appointment Dragging

4 posts, 0 answers
  1. Sean Overman
    Sean Overman avatar
    31 posts
    Member since:
    Sep 2012

    Posted 12 Apr 2011 Link to this post

    How can I cancel the appointment dragging once its started?  For example by pressing the escape key.
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 13 Apr 2011 Link to this post

    Hi Sean Overman,

    Thank you for your question.

    Here is how this could be achieved:

    //...  
    this.radScheduler1.KeyDown += new KeyEventHandler(radScheduler1_KeyDown);
     
    this.radScheduler1.SchedulerElement.DragDropBehavior.AppointmentDropping += new EventHandler<AppointmentMovingEventArgs>(DragDropBehavior_AppointmentDropping);
    //...
    private bool shouldCancelDrop = false;
     
    void DragDropBehavior_AppointmentDropping(object sender, AppointmentMovingEventArgs e)
    {
        e.Cancel = this.shouldCancelDrop;
    }
     
    void radScheduler1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Escape)
        {
            this.shouldCancelDrop = true;
            SchedulerVisualElement parent = this.radScheduler1.SchedulerElement.DragDropBehavior.ActiveFeedback.Parent as SchedulerVisualElement;
             
            this.radScheduler1.SchedulerElement.DragDropBehavior.Drop();
            foreach (AppointmentElement element in SchedulerUIHelper.GetAppointmentElements(this.radScheduler1))
            {
                element.Capture = false;
            }
     
            this.radScheduler1.SchedulerElement.DragDropBehavior.RemoveFeedback(parent);
            this.shouldCancelDrop = false;
        }
    }

    I hope this is helpful. Feel free to ask if you have any additional questions.

    Greetings,
    Ivan Todorov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Sean Overman
    Sean Overman avatar
    31 posts
    Member since:
    Sep 2012

    Posted 13 Apr 2011 Link to this post

    Thank you for the code example, how this fails to function correctly when using grouping by resource:  GroupType.Resource

    You can see the problem by adding this bit of code to your example (form_load):


    Telerik.WinControls.UI.Resource res = new Telerik.WinControls.UI.Resource();
    res.Id = new EventId(1);
    res.Name = "test emp";
    radScheduler1.Resources.Add(res);
     
    radScheduler1.GroupType = GroupType.Resource;
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 14 Apr 2011 Link to this post

    Hi Sean Overman,

    The dragging logic is a bit different when you are using grouping by resource since the appointments can be dragged between different view elements. I have tried to modify the code to work when grouping is enabled, however the public API of RadScheduler does not allow it. This scenario makes sense and we will consider improving our API in when planning our future releases.

    If you have any additional questions, do not hesitate to ask.

    Best wishes,
    Ivan Todorov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top