cancel selected node change when drag and drop

15 posts, 1 answers
  1. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 09 Apr 2010 Link to this post

    I have a treeview that when a node is selected filters items in a radpanel bar.  The rad panel bar also excepts nodes dragged to it by the treeview.  However, I am at a lose for how to prevent the selectednodechaged event from firing the filter method if drag is true.  In the NodeMouseMove event I set the IsDrag variable to true and the filter does not fire.  However, that only works once because I cannot figure out a way to set the varibale to false after the drag is complete.  DragEnd And DragStart do not fire when dragging out of the treeview. 

    Here is the code
                 private void SelectorRadTreeView_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)  
            {  
                if (!IsDrag)  
                    OnFilterGoals(this);  
            }  
    private void SelectorRadTreeView_NodeMouseDown(object sender, RadTreeViewMouseEventArgs e)  
            {  
                if (sender != null)  
                {  
                   RadTreeView myTree = sender as RadTreeView;  
                   myTree.DoDragDrop(myTree, DragDropEffects.Copy);  
                   IsDrag = true;  
                }  
            }  
            private void SelectorRadTreeView_DragEnded(object sender, RadTreeViewDragEventArgs e)  
            {  
                IsDrag = false;  
            }  
     
            private void SelectorRadTreeView_DragEnding(object sender, RadTreeViewDragCancelEventArgs e)  
            {  
                IsDrag = false;  
            } 
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 14 Apr 2010 Link to this post

    Hello steve,

    Thank you for writing.

    You can use the SelectedNodeChanging event and set the Cancel property of the tree view arguments to the value of your drag flag.

    Best wishes,
    Victor
    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. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 14 Apr 2010 Link to this post

    Thanks Victor, but that always prevent the filter event from firing.  Here is what I had to do.

            private void SelectorRadTreeView_NodeMouseDown(object sender, RadTreeViewMouseEventArgs e)  
            {  
                if (e.OriginalEventArgs.Button.Equals(MouseButtons.Left))  
                {  
                    _draggedNode = e.Node;  
                }  
            }  
            private void SelectorRadTreeView_MouseUp(object sender, MouseEventArgs e)  
            {  
                _draggedNode = null;  
            }  
            private void SelectorRadTreeView_MouseMove(object sender, MouseEventArgs e)  
            {  
                if (e.Button.Equals(MouseButtons.Left))  
                {  
                    RadTreeView myTree = sender as RadTreeView;  
     
                    //Point screenLocation = myTree.PointToScreen(e.Location);  
                    if (_draggedNode != null)  
                    {  
                        myTree.DoDragDrop(_draggedNode, DragDropEffects.Move);  
                        //_draggedNode = null;  
                    }  
                }  
            }  
            private void SelectorRadTreeView_NodeMouseUp(object sender, RadTreeViewMouseEventArgs e)  
            {  
                if (e.Node.Equals(_draggedNode))  
                {  
                    DataRowView selectorRowView = (DataRowView)SelectorRadTreeView.SelectedNode.DataBoundItem;  
                    Id = int.Parse(selectorRowView.Row[ID].ToString(), CultureInfo.InvariantCulture);  
                    OnFilter(this);  
                    _draggedNode = null;  
                }  
            } 
  5. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 15 Apr 2010 Link to this post

    I am still having an issue with the drag.  Dragging from the treeview control works fine, however, when I drag the item over the grid view I wan to drop it on, it doesn't fire the drop event.  The drag enter event fires but I the data doesn't drop into the drop event.  I have the grid set to allow drop and it was working fine before I change the tree events to allow the filter to fire. 

    I have other grids in my app and the drop icon appears when I hover over them (grid to grid).  When I drag from the treeview to any of those grids, I do not get the icon.  I also noticed that when I drag to the grid the treeview is supposed to drop on from another grid I do not the icon either. 

    The grid the treeview is supposed to drop on is inside a radpanelbar with the outlook style.  Is there anything about this style that would prevent the drop from firing?
  6. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 16 Apr 2010 Link to this post

    Hi steve,

    The issue you are describing is probably due to mixing standard OLE Drag & Drop events and the events that RadTreeView provides.

    RadTreeView's events are these:

    • DragEnded
    • DragEnding
    • DragOverNode
    • DragStarted
    • DragStarting
    • ItemDrag

    The OLE events are these:

    • DragDrop
    • DragEnter
    • DragLeave
    • DragOver
    • GiveFeedback
    • QueryContinueDrag

    Also there are drag & drop related properties declared in Control and different ones declared in RadTreeView.

    RadTreeView:

    • AllowDragDrop
    • AllowDragDropBetweenTreeViews
    • AutoScrollOnDragDrop
    • DropFeedbackColor


    Control:

    • AllowDrop


    You must use only the OLE events if you want to drag and drop between any control. For dragging and dropping between RadTreeViews, you can use either RadTreeView's events or the OLE events, just choose one set of events and use it exclusively.
    Write again if you need further assistance.

    Regards,
    Victor
    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.
  7. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 16 Apr 2010 Link to this post

    Thanks Victor.  I thought that might be the case. 
  8. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 16 Apr 2010 Link to this post

    Looks like my problem was  DragDropEffects.Copy was set to DragDropEffects.Move.  I guess somewhere I switched the code and since the data was transerfering to the grid, I never suspected Move was incorrect. 
  9. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 19 Apr 2010 Link to this post

    Hi steve,

    It is great that you spotted this issue, we are ready to assist you should you need further assistance.
     
    Regards,
    Victor
    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.
  10. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 27 Apr 2010 Link to this post

    I noticed a weird problem with the radtreeview.  If you expand the treeview one node passed the horizontal scrolls the mouse up does not fire.  Is this a know issue?
  11. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 27 Apr 2010 Link to this post

    Hello steve,

    Thank you for writing. Unfortunately, I could reproduce that issue. Could you provide a sample that reproduce it (you will need to open a new support ticket) and/or send us the steps in order to verify that issue?

    All the best,
    Dobry Zranchev
    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.
  12. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 27 Apr 2010 Link to this post

    ok, should have it by this after noon.
  13. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 27 Apr 2010 Link to this post

    Each time I try to submit a support ticket, it only allows mt to submit a ticket for ASP.net Ajax and some other product.  Is there something wrong with the site?
  14. Donna
    Admin
    Donna avatar
    67 posts

    Posted 29 Apr 2010 Link to this post

    Hello Steve,

    It seems there has been a temporarily glitch in our system, which is why your account has not been showing correct support ticket options. Please accept our apologies for any incontinence this error might have caused. The problem has been fixed already and you should not have any problems submitting a ticket for the correct product line.

    If I can be of any additional assistance, please let me know.
     
    Best wishes,
    Donna
    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.
  15. steve
    steve avatar
    81 posts
    Member since:
    Oct 2009

    Posted 29 Apr 2010 Link to this post

    Thanks, Donna! The ticket was submitted thanks.
  16. Donna
    Admin
    Donna avatar
    67 posts

    Posted 05 May 2010 Link to this post

    You are very welcome, Steve! I'm glad I could help. :)

    All the best, Donna
    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
UI for WinForms is Visual Studio 2017 Ready