Drag and Drop

36 posts, 0 answers
  1. New2UI
    New2UI avatar
    7 posts
    Member since:
    Apr 2007

    Posted 17 May 2007 Link to this post

    Telerik Team,

    Can you drag and drop a row with this control? I am currently using Q1 2007 version.

    THanks

  2. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 18 May 2007 Link to this post

    Hi Nemesio,

    In its current version RadGridView does not support drag&drop functionality. Can you provide us with more detailed scenario that require such a behavior? We will evaluate all feature requests and will update our ToDo list accordingly. We are planning to provide  drag&drop of rows in one of our next releases.

    Greetings,
    Jack
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center

  3. dootndo2
    dootndo2 avatar
    10 posts
    Member since:
    Dec 2006

    Posted 16 Oct 2007 Link to this post

    I am looking to add rows by dragging and dropping items onto the grid.  Is this possible yet?  I am now on 2007 Q2.  
     
    We are trying to allow the user to drag from the RadGridView to a separate control that supports DragDrop.  If they change their mind, they can drag the item from the separate control back to the RadGridView (re-add the row).

    Thanks.

    Dennis

  4. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 16 Oct 2007 Link to this post

    Hello dootndo2,

    Thank you for this question.

    The RadGridView doesn't support these drag & drop operations automatically.This feature must be implemented manually.

    In order to enable drag & drop operations in the RadGridView you must process certain standard WinForms events. To enable dropping rows to other controls you must attach to MouseDown and MouseMove events and call the DoDragDrop function. To receive dropped rows you must process DragEnter, DragDrop and DragLeave events.

    You can find additional information how to implement drag & drop operations on the MSDN site. Follow this link for more information:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dragndropops.asp

    We hope this helps you. Don't hesitate to contact us if you have any other questions.

    Sincerely yours,
    Jack
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center

  5. starlinxy
    starlinxy avatar
    14 posts
    Member since:
    Mar 2007

    Posted 02 Jun 2008 Link to this post

    is there drag and drag supported in the new windows control?  Can you provide an example of how to drag and drop and maintain the focus?

  6. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 03 Jun 2008 Link to this post

    Hi starlinxy,

    Thank you for the question.

    Drag & drop operations are natively supported by the .Net framework. You should set the AllowDrop property to true and process the events mentioned in the previous post.

    Please give me more details on the exact behavior you want to achieve. What do you mean by maintaining the focus? I will be glad to help you further with this issue.

    Do not hesitate to contact me if you have other questions.

    Regards,
    Jack
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center

  7. starlinxy
    starlinxy avatar
    14 posts
    Member since:
    Mar 2007

    Posted 03 Jun 2008 Link to this post

    We want to have 2 data bound gridviews then drag from gridview A to gridview B.  When dragging to gridview B we want the record that the mouse is currently on to be focused so that the user knows where the the item will be dragged and dropped.  After this we would need to know the unique ID of where the focus was on B so we can drop the item and insert into database appropriately.  Here is an example

    Grid A contains
    ID        FruitNames
    ----------------------
    1            Apple             
    2            Orange
    3            Kiwi
    4            Strawberry

    Grid B Contains
    ID         FruitNames
    ----------------------
    1        Pear    
    2        Watermellon
    3        Banana

    When the user drags Orange from Grid A over to Grid B and places their mouse cursor on top of Watermellon we want to highlight this Watermellon row immediately.  Then in the back end find the row ID 2 so that we can use that to insert Orange between those 2 items or even replace it appropriately.

    We can't find a way to highlite the row appropriately and figure out a way how to get the row selected based on where the mouse is.  If you can setup a simple demo for us that would be great.

  8. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 03 Jun 2008 Link to this post

    Hello starlinxy,

    Thank you for getting back to me.

    Please find attached a sample project implementing simple drag & drop behavior. You should use the GetElementAtPoint to find the GridRowElement at specific mouse coordinates.

    Consider the following code snippet:

    GridViewRowInfo GetRowAtPoint(RadGridView grid, Point location) 
        RadElement element = grid.ElementTree.GetElementAtPoint(location); 
        if (element is GridCellElement) 
        { 
            return ((GridCellElement)element).RowInfo; 
        } 
        if (element is GridDataRowElement) 
        { 
            return ((GridRowElement)element).RowInfo; 
        } 
        return null
     

    I hope this helps. Please let me know if you have other questions.

    Kind regards,
    Jack
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  9. Patrick
    Patrick avatar
    6 posts
    Member since:
    Sep 2007

    Posted 31 Dec 2008 Link to this post

    I have a different question related to drag and drop. I am using Q3 2008. Does the RadGrid support items drag and drop? I would like to manually sort the list by dragging and dropping rows within the same grid (You do support this in the ASP version).


    Thanks,

    Patrick. 

  10. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 05 Jan 2009 Link to this post

    Hello Patrick,

    No, this feature is not supported in RadGridView for WinForms. You could use code similar to the one described in the previous post. We will consider implementing this feature in one of our upcoming releases.

    I will be glad helping you further.

    Kind regards,
    Jack
    the Telerik team


    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  11. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 26 May 2009 Link to this post

    Hello!

    Is there any indication of when will this be available? Seems a lot of folks out there is wanting Drag n' Drop behavior for the RadGridView. Me included! :)

    In the meanwhile, I'll have to code the behavior as it was suggested here.

  12. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 26 May 2009 Link to this post

    Hi Stargazer,

    I can't give you an exact time frame when it will be implemented. It isn't planned yet. However, we will discus this issue when planning our Q3 release. Of course, if more people request the same functionality we will increase its priority.

    Should you have any other questions, don't hesitate to ask.

    Greetings,
    Jack
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  13. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 26 May 2009 Link to this post

    Well, in fact, what I need to do is moving rows between bound grids... A slightly different achievement from the one on this thread. I'll try to explain.

    I have two BindingLists of a custom business object. Then I have two RadGridViews bound to those lists. I want to let the user drag and drop rows from one to the other, affecting the bound lists as the rows get removed or added to each of the RadGridViews. I'm also wanting to use multi selection, so It should let me drag more than one row.

    I'm not so sure how I can achieve this one... :S

  14. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 26 May 2009 Link to this post

    Hello Jack!

    Thanks for the reply. I'll be waiting, then. And hopping that more people ask for this... hehehe

    Regards!

  15. Mirko
    Mirko avatar
    8 posts
    Member since:
    May 2007

    Posted 15 Sep 2009 Link to this post

    Hello,

    Anybody knows how to drag griditem from gridview to the desktop or a windows folder?

    Mirko

  16. Victor
    Admin
    Victor avatar
    1208 posts
    Member since:
    Sep 2012

    Posted 17 Sep 2009 Link to this post

    Hi Mirko,

    In order to do this you will have to make use of the native Win32 API since the windows forms drag and drop mechanism does not support un-managed drop targets. Write again if you have other questions.

    Greetings,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  17. Niklas
    Niklas avatar
    7 posts
    Member since:
    Apr 2009

    Posted 30 Sep 2009 Link to this post

    My problem is when I allow MultiSelect the selection changes to the row i clicked.

    Same problem described in this post but i am using RadControls for WinForms Q2 2009 SP1.

    Any suggestions?

  18. Victor
    Admin
    Victor avatar
    1208 posts
    Member since:
    Sep 2012

    Posted 06 Oct 2009 Link to this post

    Hi Niklas,

    Thank you for your question. In order to get the selected rows before they are cleared, you have to set the grid behavior to a custom one and override OnMouseDown so that you can get the rows before the base logic. For example:
    public class MyGridBehavior : BaseGridBehavior 
        private List<GridViewRowInfo> rows = new List<GridViewRowInfo>(); 
        public override bool OnMouseDown(MouseEventArgs e) 
        { 
            this.rows.Clear(); 
            foreach(GridViewRowInfo r in this.GridControl.SelectedRows) 
            { 
                rows.Add(r); 
            } 
            return base.OnMouseDown(e); 
        } 
     
        public List<GridViewRowInfo> SelectedRows 
        { 
            get 
            { 
                return this.rows; 
            } 
        } 

    Now you need to create an instance of this behavior, keep a reference to it, and set it to RadGridView like so:
    MyGridBehavior behavior = new MyGridBehavior(); 
    this.radGridView1.GridBehavior = behavior; 

    After this is in place you have to handle MouseDown event of RadGridView and get the selected rows through MyGridBehavior reference.

    Write again if you have other questions.

    Regards,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  19. Calago
    Calago avatar
    65 posts
    Member since:
    Feb 2008

    Posted 14 Oct 2009 Link to this post

    Hello,

    I am having the same challenge as Niklas: I want to be able to select multiple rows from a RadGridView and drag and drop them onto a RadTreeView. The code examples with OnMouseDown in combination with the custom GridBehavior works, but is not ideal yet. When you select multiple grid rows and then click again to drag them, it looks like only one row is selected. After you drop them you have to select the other rows again if you want to drag the same rows again somewhere else...

    Any suggestions how I can improve this? And I know it has been asked before, but when do you think that drag and drop is fully implemented in the RadGridView? I could really use it :-)

    Thanks in advance.

  20. Victor
    Admin
    Victor avatar
    1208 posts
    Member since:
    Sep 2012

    Posted 19 Oct 2009 Link to this post

    Hi A. Bennen,

    You could easily work around this issue by keeping a collection of the selected rows and setting them to selected again after the drag & drop operation is finished. You can create this temporary collection before you begin the Drag & Drop operation. Please write again if you have other questions.

    Best wishes,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  21. Nathaniel
    Nathaniel avatar
    12 posts
    Member since:
    Feb 2009

    Posted 13 Nov 2009 Link to this post

    I think A. Bennen was referring to the problem that I am encountering. When dragging and dropping on the Telerik GridView with multiple rows selected, the selection is reduced to a single row on MouseDown (unless the CTRL key is pressed). This is very unintuitive behavior. The selection should not be reduced to a single row until MouseUp. Users expects that when they begin to drag, ALL of the selected rows will remain selected until they release the mouse on an acceptable target. It is NOT an acceptable workaround to just reselect the rows after the drag/drop is completed because WHILE the user is dragging it appears that they are only dragging one row.

    I found the other thread where it was shown how to create a bitmap of the rows that you are dragging. This is nice, but the original problem remains. I ask outright: why is the row selection reduced to a single row on MouseDown instead of MouseUp? Is this something that can be fixed? We need to have an acceptable fix or workaround or I cannot convince my manager to use the Telerik GridView.

    Thank you,
    NC

  22. Nathaniel
    Nathaniel avatar
    12 posts
    Member since:
    Feb 2009

    Posted 16 Nov 2009 Link to this post

    For the benefit of others: Support sent me this code sample, which demonstrates an acceptable workaround.

    http://www.telerik.com/ClientsFiles/158846_dragndrop.zip

  23. Marcello
    Marcello avatar
    7 posts
    Member since:
    Dec 2008

    Posted 22 Apr 2010 Link to this post

    Hi,

    we are very interested in a native Drag and Drop between grids. Is supported in Q1-2010  version?

    Marcello

  24. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 23 Apr 2010 Link to this post

    Hi Nathaniel,

    Drag and drop is not supported naively yet. As demonstrated in this thread it could be easily implemented with a few lines of code. Please, tell us whether this solution is suitable for you. If not, describe the exact behavior that you want to achieve and I will be glad to assist you.

    We will have in mind the drag & drop feature and we will try to implement it in a future release. Could you please describe what you expect from this feature? We will appreciate your feedback.

     
    Kind regards,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  25. sonu
    sonu avatar
    2 posts
    Member since:
    Nov 2007

    Posted 30 Aug 2010 Link to this post

    Hi,

    Can u tell me , how can i select multiple grid rows by mouse click..

    Thanks

  26. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 30 Aug 2010 Link to this post

    Hello sonu,

    Thank you for this question.

    First, you have to set the MultiSelect property to true and SelectionMode to FullRowSelect. Here is a sample:

    this.radGridView1.MultiSelect = true;
    this.radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.FullRowSelect;

    You have two options when using mouse to select rows:

    1.
    Keep pressed the Control key and click on the rows that you want  to select.
    2. Keep the left mouse button pressed and start dragging over the rows that you want to select.

    I hope this helps. If you have any other questions, do not hesitate to contact us.

    Sincerely yours, Jack
    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

  27. John
    John  avatar
    16 posts
    Member since:
    Jan 2011

    Posted 08 Mar 2011 Link to this post

    Thanks for these samples. I've tried both the files referenced here (087627_GridDragDrop.zip and 158846_dragndrop.zip), and neither of them work with the current framework. The errors are along the lines of:

    Error 1 'Telerik.WinControls.UI.GridViewRowInfo' does not contain a definition for 'VisualElement' and no extension method 'VisualElement' accepting a first argument of type 'Telerik.WinControls.UI.GridViewRowInfo' could be found (are you missing a using directive or an assembly reference?) D:\dev\bex2\GridDragDrop\GridDragDrop\Form1.cs 65 41 GridDragDrop

    The XAML version mentioned elsewhere in the thread is working, but that's for the XAML GridView rather than the WinForms one. Is there an updated example for the WinForms control? Or is this now a "native" feature of the GridView and I'm just missing the steps to set it in the latest version?

  28. Jack
    Admin
    Jack avatar
    2208 posts
    Member since:
    Sep 2012

    Posted 16 Mar 2011 Link to this post

    Hi John ,

    Both projects represent the same solution. I modified it to be compatible with our latest release, please check the attached project. 

    There is an example demonstrating drag & drop between grids in our demo application. It is located under GridView >> Rows >> Rows Drag & Drop.

    Should you have any further questions, do not hesitate to ask.

    All the best,
    Jack
    the Telerik team

    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

  29. John
    John  avatar
    16 posts
    Member since:
    Jan 2011

    Posted 13 Apr 2011 Link to this post

    Thanks for the update. Sorry for the late reply - the notification was in my junk mail folder

Back to Top