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

How to remove a column from grid while dragging that column outside of column header section in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl

Remove a header column

In order to remove a column while dragging that column outside of the column header section, the Tablecontrol.MouseUp and TableControl.MouseDown events can be handled. The TableControl.MouseDown is used to get the header column and that retrieved column can be removed by using VisibleColumns property in Tablecontrol.MouseUp.


//Event subscription.
this.gridGroupingControl1.TableControl.MouseDown += new MouseEventHandler(TableControl_MouseDown);
this.gridGroupingControl1.TableControl.MouseUp += new MouseEventHandler(TableControl_MouseUp);
//Handling the TableControl_MouseUp event.
void TableControl_MouseUp(object sender, MouseEventArgs e)
    GridTableControl tableControl = sender as GridTableControl;
    int rowIndex, colIndex;
    tableControl.PointToRowCol(e.Location, out rowIndex, out colIndex);
    GridTableCellStyleInfo style = tableControl.GetTableViewStyleInfo(rowIndex, colIndex);
    if (style.TableCellIdentity.DisplayElement.Kind != DisplayElementKind.ColumnHeader && column != null)
    column = null;
//Handling the TableControl_MouseDown event.
void TableControl_MouseDown(object sender, MouseEventArgs e)
    GridTableControl tableControl = sender as GridTableControl;
    GridTableCellStyleInfo style = (GridTableCellStyleInfo)tableControl.PointToTableCellStyle(new Point(e.X, e.Y));
    if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.ColumnHeader)
        column = style.TableCellIdentity.Column;



'Event subscription.
AddHandler gridGroupingControl1.TableControl.MouseDown, AddressOf TableControl_MouseDown
AddHandler gridGroupingControl1.TableControl.MouseUp, AddressOf TableControl_MouseUp
'Handling the TableControl_MouseUp event.
Private Sub TableControl_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
      Dim tableControl As GridTableControl = TryCast(sender, GridTableControl)
      Dim rowIndex, colIndex As Integer
             tableControl.PointToRowCol(e.Location, rowIndex, colIndex)
      Dim style As GridTableCellStyleInfo = tableControl.GetTableViewStyleInfo(rowIndex, colIndex)
      If style.TableCellIdentity.DisplayElement.Kind <> DisplayElementKind.ColumnHeader AndAlso column IsNot Nothing Then
      End If
      column = Nothing
End Sub
'Handling the TableControl_MouseDown event.
Private Sub TableControl_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
      Dim tableControl As GridTableControl = TryCast(sender, GridTableControl)
      Dim style As GridTableCellStyleInfo = CType(tableControl.PointToTableCellStyle(New Point(e.X, e.Y)), GridTableCellStyleInfo)
      If style.TableCellIdentity.DisplayElement.Kind = DisplayElementKind.ColumnHeader Then
          column = style.TableCellIdentity.Column
      End If
End Sub


Before remove the columns in header

After removing column

After remove the column in header


C#: Removing_Columns

VB: Removing_Columns

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile