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 GridControl

hi,

i've a datagrid(GridControl) as shown as below:

Col1 Col2 Total
----- ------ ------ -----
Row1
Row2
Total

how do i prevent user drag the row or column after the Row Total or Col Total?


5 Replies

HA haneefm Syncfusion Team June 4, 2007 04:03 PM UTC

Hi Lim,

You can prevent the column dragging by handling the QueryAllowDragColumnHeader event and setting the e.AllowDrag property to False to prevent from moving the column header in a grid. Here is a code snippet

private void gridQueryAllowDragColumnHeader(object sender, GridQueryDragColumnHeaderEventArgs e)
{
if( e.InsertBeforeColumn >= 3 )
e.AllowDrag = false;
}

Best regards,
Haneef


AA aa June 5, 2007 06:40 AM UTC



>Hi Lim,

You can prevent the column dragging by handling the QueryAllowDragColumnHeader event and setting the e.AllowDrag property to False to prevent from moving the column header in a grid. Here is a code snippet

private void gridQueryAllowDragColumnHeader(object sender, GridQueryDragColumnHeaderEventArgs e)
{
if( e.InsertBeforeColumn >= 3 )
e.AllowDrag = false;
}

Best regards,
Haneef


hi haneef,

The event does't fire, anything that i missed out?

Besides to control the dragging Column, how abount the Row header? My datagrid is a two dimensional grid(GridControl).

Thanks for help!


HA haneefm Syncfusion Team June 5, 2007 10:29 PM UTC

Hi Lim,

You can handle the SelectionDragging event. The GridSelectionDragEventArgs contain information about source and destination range. For specified columns/rows you can then set e.Cancel = true. Below is a code snippet

[c#]
void gridControl1_SelectionDragging(object sender, GridSelectionDragEventArgs e)
{
if (e.Destination.IntersectsWith(GridRangeInfo.Row(5))) //5th row drag over
e.Cancel = true;
else if (e.Destination.IntersectsWith(GridRangeInfo.Row(3))) //3rd column drag over
e.Cancel = true;
}

Best regards,
Haneef


AA aa June 6, 2007 01:40 PM UTC

hi haneef,

The method does't work fine...

The col and row cannot be dragged when i applied the code..

Could you please write me a demo project?
Urgent please..
Thanks!







HA haneefm Syncfusion Team June 6, 2007 03:52 PM UTC

Hi Lim,

Here is a minimal sample that shows you "How to prevent the dragging of the selected rows or columns in a grid?".
GridControlSelectionDrag.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon