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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Drag and drop in GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

61852 Jun 4,2007 07:52 AM UTC Jun 6,2007 03:52 PM UTC WinForms 5
loading
Tags: GridControl
aa
Asked On June 4, 2007 07:52 AM UTC

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?


haneefm [Syncfusion]
Replied On 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
Replied On 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!

haneefm [Syncfusion]
Replied On 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
Replied On 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!






haneefm [Syncfusion]
Replied On 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

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.

Please sign in to access our forum

or the page will be automatically redirected to 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

;