Scrollbar & Drag&Drop

3 posts, 1 answers
  1. Ludovic Alcala
    Ludovic Alcala avatar
    24 posts
    Member since:
    Jan 2010

    Posted 26 Mar 2010 Link to this post

    Hello,
    when i scroll in my radgridview, i cannot block the drag of my elements.
    I manage my dragged elements by RadDragAndDropManager like that :

    ctor()
    {
    RadDragAndDropManager.AddDragQueryHandler(ListingProductGridView, OnRadGridViewDrag);
    RadDragAndDropManager.AddDragInfoHandler(ListingProductGridView, OnRadGridViewDragInfo);
    }



    and in events :
    private void OnRadGridViewDragInfo(object sender, DragDropEventArgs e)
            {
                RadGridView gridView = sender as RadGridView;
                IEnumerable draggedItems = e.Options.Payload as IEnumerable;
                if (e.Options.Status == DragStatus.DragInProgress)
                {
                    TreeViewDragCue cue = new TreeViewDragCue();
                    cue.ItemTemplateSelector = new ProductCategoryTemplateSelector() { MySize = ProductCategoryTemplateSelector.Size.Large };
                    cue.ItemsSource = draggedItems;
                    e.Options.DragCue = cue;
                }
                else if (e.Options.Status == DragStatus.DragComplete)
                {
                    // Fin d'opération de dragging

                }
            }
            private void OnRadGridViewDrag(object sender, DragDropQueryEventArgs e)
            {
                RadGridView gridView = sender as RadGridView;
                if (gridView != null)
                {
                    IList selectedItems = gridView.SelectedItems.ToList();
                    e.QueryResult = selectedItems.Count > 0;
                    e.Options.Payload = selectedItems;
                    e.QueryResult = true;
                    e.Handled = true;
                }

            }


     But when i scroll, i have my dragged items on the scrollbar, can i block that ?

    Thank you.





  2. Answer
    Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 29 Mar 2010 Link to this post

    Hi Ludovic Alcala,

    Please check the attached project. It demonstrates how to avoid dragging when performing scroll. The idea is to get the element below the mouse when the drag starts. It can be achieved using the following code:
    if (e.Options.Status == DragStatus.DragQuery)
    {
        e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
        var element = e.GetElement<ScrollBar>(e.Options.MouseClickPoint);
        e.QueryResult = e.QueryResult.Value && element == null;
    }


    Regards,
    Tsvyatko
    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. DevCraft banner
  4. Ludovic Alcala
    Ludovic Alcala avatar
    24 posts
    Member since:
    Jan 2010

    Posted 29 Mar 2010 Link to this post

    Thank you, it works :)
Back to Top