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

Allow user to drag column from GridGroupingControl to remove from table

Hi,

I'm having trouble figuring out how to allow the user to drag a column from a GridGroupingControl off the control in order to remove it.

I want it to work the same as in Outlook when you drag a column header off the grid.

I saw the post here:
http://www.syncfusion.com/support/forums/grid-windows/53250/How-to-Remove-a-Column-from-Visible-Columns-Collection-by-Dragging-its-Column-Header-from-GridGroupingControl

however the link with the sample app is broken?

Thanks

1 Reply

CI Christopher Issac Sunder K Syncfusion Team April 28, 2010 02:19 PM UTC

Hi Jeff,

Thank you for your interest in Syncfusion products.

Your mentioned requirement can be achieved by handling the Tablecontrol_mouseUp and TableControl_MouseDown events in GridGroupingControl. The TableControl_MouseDown is used to catch the HeaderColumn and that retrieved column is removed by calling the Tablecontrol_mouseUp whether the mouse pointer is not in the column header.


GridColumnDescriptor col = new GridColumnDescriptor();
void TableControl_MouseDown(object sender, MouseEventArgs e)
{
GridTableControl tableControl = sender as GridTableControl;
GridTableCellStyleInfo style = (GridTableCellStyleInfo)tableControl.PointToTableCellStyle(new Point(e.X, e.Y));
Point pt = tableControl.PointToClient(Control.MousePosition);

if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.ColumnHeader)
{
col = style.TableCellIdentity.Column;
}
}

void TableControl_MouseUp(object sender, MouseEventArgs e)
{
GridTableControl tableControl = sender as GridTableControl;
GridTableCellStyleInfo style = (GridTableCellStyleInfo)tableControl.PointToTableCellStyle(new Point(e.X, e.Y));
Point pt = tableControl.PointToClient(Control.MousePosition);

if (style.TableCellIdentity.DisplayElement.Kind != DisplayElementKind.ColumnHeader && col!=null)
{
this.gridGroupingControl1.TableDescriptor.VisibleColumns.Remove(col.ToString());
}
col = null;
}


Please refer the sample link which allows user to drag column from GridGroupingControl to remove from table.

http://help.syncfusion.com/support/samples/Grid.Windows/8.2.0.18/F94064.zip

Please let me know if you have any further concerns

Regards,
Christopher K.

Loader.
Live Chat Icon For mobile
Up arrow icon