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
close icon

Drag and Drop in WPFGridDataControl?

Hi,

Do you have any code snippet of drag-drop feature for GridDataControl? Eg. I want to move 5th row to first. Thanks.


9 Replies

DM Deenadhayalan M Syncfusion Team June 23, 2011 09:56 AM UTC

Hi Tun,

Sorry for the inconvenience caused.

Currently, Our GridDataControl doesn't support for Drag and drop the rows. We can drag and drop the columns. But you can Move the Row using MoveRows property as follows,

Code snippet [C#] :
this.datagrid.Model.MoveRows(5, 1, 1);

We have prepared a sample based on this. Please find the sample in the following location.

Regards,
Deenadhayalan



99715_GridDataVisible_61437dee.zip


TN Tun Nwe Aung June 24, 2011 01:50 AM UTC

Thank you for your reply. But, After clicking on Move Button, if you click on the cell, it goes back to the original state.

Eg. Before clicking "Move"
1
2
3
4
5
After clicking "Move"
5
4
3
2
1

But , If you click on each cell at that time, it changed back to 1,2,3,4,5 again. Please advise. Thanks.




TN Tun Nwe Aung June 24, 2011 02:28 AM UTC

And, plus this, In my GridDataControl, I added ScrollViewer.CanContentScroll="True" , so that I can see the scrollbar in the grid. But, Is there any way to move this scrollbar up and down programatically? I'm really stuck in this stage and much appreciate if you can help it out. Please advise. Thank you.



TN Tun Nwe Aung June 28, 2011 04:29 AM UTC

Scrolling problem is solved , just left the MoveRows issue. Thanks.



DM Deenadhayalan M Syncfusion Team June 29, 2011 04:14 AM UTC

Hi Tun,

Sorry for the inconvenience caused.

The MoveRows method useful to see the item visually at particular position. To move the row permanently to a particular position, you need to modify the item position of underlying Collection as follows,

private void Button_Click(object sender, RoutedEventArgs e)
{
if (this.datagrid.Model[5, 0].CellValue.ToString() == "Carl")
{
Collection.Move(4, 0);
}
}

We have prepared a sample based on this. Please find in the following location.

Please let us know if you have any queries.

Regards,
Deenadhayalan



99715_GridDataVisible_MoveRows_b803ca9b.zip


TN Tun Nwe Aung June 29, 2011 08:26 AM UTC

Thank you for your reply. Yes, this is the problem I'm facing right now. If you want to change the underlying collection, you have to set the AllowSort to fasle. If you want to sort, you cannot move. Is there anything that makes both to work simultaneously. Once again, thank you for your reply.



RV Ramesh V Syncfusion Team July 1, 2011 01:13 PM UTC

Hi Tun,

Sorry for the inconvenience caused.

At present there is no support to change the underlying collection item positions and also Sorting at the same time. We can perform any one at a time.

Please let us know if you have any queries.

Regards,
Ramesh




MC Michael Culley October 7, 2011 12:18 AM UTC

You can drag and drop rows if you implement drag and drop functionality yourself. This isn't 100% straight forward but not too difficult. See the attached sample, it is demonstrating dragging from a grid on the left to one on the right but it would be a simple modification to drag from a grid to itself. Note that in some cases you get 2 drop events but this is something I have raised with support. It's fairly easy to set a flag to ignore the second event.



SFGridDragDrop_585e7438.zip


JJ Jawahar Jeevanandan J Syncfusion Team November 2, 2011 05:43 PM UTC

Hi Michael,

Thanks for your patience.

The query reported in this forum has been addressed in incident 85682. Please follow incident 85682 incident for further follow up.

Please let us know if you have any queries.

Thanks,
Jawahar.


Loader.
Live Chat Icon For mobile
Up arrow icon