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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Inserting a row using DnD

Thread ID:





7922 Oct 14,2003 06:02 PM UTC Oct 15,2003 06:23 PM UTC WinForms 3
Tags: GridControl
Paul Muller
Asked On October 14, 2003 06:02 PM UTC

Your drag and drop capability is very nice. I can go from one grid to another or within a grid. Is there a property or method for dropping a row in the middle of a grid without overwriting an existing row? Thanks, Paul

Administrator [Syncfusion]
Replied On October 14, 2003 09:38 PM UTC

No, but you can catch the DragDrop event and insert a row at that point to catch the dropped row.
private void gridControl1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
	Point pt = this.gridControl1.PointToClient(Control.MousePosition);
	int row, col;
	this.gridControl1.PointToRowCol(pt, out row, out col, -1);

Paul Muller
Replied On October 15, 2003 04:11 PM UTC

Unless I converted your code to VB improperly, there seems to be a bug. When I have a grid with 5 rows and I try to drag row 4 to tow 1, the result is 4, 1, 2, blank, 4, 5 instead of 4, 1, 2, 3, 5. Row 3 has disappeared! Here is my code: Private Sub GridControl2_DragDrop1(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles GridControl2.DragDrop Dim pt As New Point pt = Me.GridControl2.PointToClient(Control.MousePosition) Dim row, col As Integer Me.GridControl2.PointToRowCol(pt, row, col) If Len(Me.GridControl2(row, 1).CellValue) > 0 Then Me.GridControl2.Rows.InsertRange(row, 1) End If ''''Me.GridControl2.Rows.RemoveRange(rowFrom, 1) End Sub

Administrator [Syncfusion]
Replied On October 15, 2003 06:23 PM UTC

When you drag a higher numbered row to a lower numbered row in the same grid, then inserting the new row for the dropped effectively increases the source row number by 1. This means that when the OLE code goes onto clear the source row, it clears the row immediately preceding the source row. The OLE D&D code has no knowledge that you have inserted a row above the source row. So, if you need this functionality, you will have to work around this problem. Attached is one try at this. It uses the Clearing cells event to try to clear the proper row. It assumes you are only dragging 1 row. If you want to support dragging multiple rows, then you would have to extend this code to handle that.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon