We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid drag and drop selection behavior

I'm trying to implement drag and drop functionality with the unbound grid. What I'd like to be able to do is select multiple rows and drag those onto another control on my form. I've figured out this part of the process and it works. However, I can't seem to figure out how to get make the selection behavior similar to the way it works in Windows Explorer. If I have five rows in my datagrid, and I control-click rows 1, 3, and 5, if I don't drag on the last click but click on row 5 (or another selected row) and then drag, I lose the selection I last clicked, but get all the previous rows I selected. So the behavior in this scenario seems to exclude the last row selected, even though I clicked on it again with the control key pressed. Also, if I don't keep the control key pressed I'll only get the row I clicked and dragged (the grid will deselect the other previously selected rows). If you try this with a group of files within Windows Explorer you can see that behavior and then compare it to how the grid works. My question - how do I achieve similar selection behavior with the grid? Thanks! -Paul

1 Reply

AD Administrator Syncfusion Team August 20, 2003 04:38 AM

> I'm trying to implement drag and drop functionality with the unbound grid. What I'd like to be able to do is select multiple rows and drag those onto another control on my form. I've figured out this part of the process and it works. > > However, I can't seem to figure out how to get > make the selection behavior similar to the way it works in Windows Explorer. If I have five rows in my datagrid, and I control-click rows 1, 3, and 5, if I don't drag on the last click but click on row 5 (or another selected row) and then drag, I lose the selection I last clicked, but get all the previous rows I selected. So the behavior in this scenario seems to exclude the last row selected, even though I clicked on it again with the control key pressed. Also, if I don't keep the control key pressed I'll only get the row I clicked and dragged (the grid will deselect the other previously selected rows). > > If you try this with a group of files within Windows Explorer you can see that behavior and then compare it to how the grid works. > > My question - how do I achieve similar selection behavior with the grid? > > Thanks! > -Paul The default behavior of the grid only initiates an OLE D&D if you mousedown when your see the D&D cursor. And you only see this cursor when you move the mouse to a border of the last selected range. This is why when you click somewhere else (any where other than the border of the last selection), then grid processes it as a new click. If you want to initiate a D&D no matter where you click, I think you will have to handle the mouse events, and explicitly call DoDragDrop to initialte your own D&D. Attached is some sample code that handles starting a custom D&D when you mousedown (anywhere in the cell) and move a selected cell.

Loader.
Live Chat Icon For mobile
Up arrow icon