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

Inserting a row using DnD

Thread ID:

Created:

Updated:

Platform:

Replies:

7922 Oct 14,2003 02:02 PM Oct 15,2003 02:23 PM Windows Forms 3
loading
Tags: GridControl
Paul Muller
Asked On October 14, 2003 02:02 PM

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 05:38 PM

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);
	this.gridControl1.Rows.InsertRange(row,1);
}

Paul Muller
Replied On October 15, 2003 12:11 PM

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 02:23 PM

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.

CONFIRMATION

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.

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.

;