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 Column Drag and Drop

Hi,

I have 2 Grids on one of my windows. The top grid does some custom analytics on the data from the lower grid. I want to be able to drag the column from the lower grid and capture it on the another grid.

I am able to drag the range of cells from the lower grid but not able to drag the column header. And I need only the column header of the column which I am dragging to the upper Grid.

I looked into the grid samples provided by syncfusion but they all show drag and drop for the cell or range of cell values and not the column header.

Any help will be appreciated.

Regards,
Sugandha Aggarwal

6 Replies

HA haneefm Syncfusion Team August 6, 2007 05:51 PM UTC

Hi Sugandha,

Moving columns is support by default in a Grid. If you click a colheader to select the column, then if you mousedown on the selected column header, you can drag and drop it in another position.

If you do not see this behavior, check the AllowDragSelectedCols property to make sure it is on. Try turning on this property and enable the DragColumnHeader flag in the Controller option.

this.grid.AllowDragSelectedCols = true;
this.grid.ControllerOptions |= GridControllerOptions.DragColumnHeader;

Best regards,
Haneef


SA Sugandha Aggarwal August 7, 2007 06:53 AM UTC

Hi Haneef,

Thanks for the reply, but my problem is not dragging the column header within the same grid. I want to drag that column header to the other grid and want to capture the name at the drop on the other grid.

DragColumnHeader flag in the Controller option helps in dragging the column header but I am not able to capture it in the other grid. Please help.

Regards,
Sugandha


SA Sugandha Aggarwal August 7, 2007 06:53 AM UTC

Hi Haneef,

Thanks for the reply, but my problem is not dragging the column header within the same grid. I want to drag that column header to the other grid and want to capture the name at the drop on the other grid.

DragColumnHeader flag in the Controller option helps in dragging the column header but I am not able to capture it in the other grid. Please help.

Regards,
Sugandha


SA Sugandha Aggarwal August 9, 2007 05:22 AM UTC

Hi,

I am still waiting for some input from anybody.

Regards,
Sugandha Aggarwal

>Hi Haneef,

Thanks for the reply, but my problem is not dragging the column header within the same grid. I want to drag that column header to the other grid and want to capture the name at the drop on the other grid.

DragColumnHeader flag in the Controller option helps in dragging the column header but I am not able to capture it in the other grid. Please help.

Regards,
Sugandha


MW Melba Winshia Syncfusion Team August 10, 2007 02:14 PM UTC

Hi Sugandha,

If your intention is to drag the column from one grid to the other grid you can use OleDragDrop to move a column.

Please refer the below link which illustrates the above.

http://websamples.syncfusion.com/samples/Frid.Windows/66951/main.htm

And you can use QueryAllowDragcolumnHeader event to capture the name.

[C#]

void gridDataBoundGrid1_QueryAllowDragColumnHeader(object sender , GridQueryDragColumnHeaderEventArgs e)
{

int field = gridDataBoundGrid1.Binder.ColIndexToField(2);
string colname = gridDataBoundGrid1.Binder.InternalColumns[field].MappingName;

}

Please try this and let me know if this helps.

Thanks,
Melba



MW Melba Winshia Syncfusion Team August 10, 2007 02:15 PM UTC

Hi Sugandha,

If your intention is to drag the column from one grid to the other grid you can use OleDragDrop to move a column. And you can use DragOver event to capture the name.

[C#]

private void gridControl2_DragOver(object sender, DragEventArgs e)
{
e.Effect=DragDropEffects.Copy;
GridCurrentCell cc = this.gridControl1.CurrentCell;
int colindex = cc.ColIndex;
string column = GridRangeInfo.GetAlphaLabel(colindex);
Console.WriteLine(column);

}

Please refer the below link which illustrates the above.

http://websamples.syncfusion.com/samples/Grid.Windows/66951/main.htm

Please try this and let me know if this helps.

Thanks,
Melba


Loader.
Live Chat Icon For mobile
Up arrow icon