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 unhide the column after dragging it to hide in WinForms GridControl?

Platform: WinForms |
Control: GridControl

Resizing hidden column

The default behavior to unhide a column is to double click the column’s border. When you just want to drag and resize the hidden columns, you can do it by handling the ResizingCols event.

In the following code example resizing hidden columns in gridcontrol is done by using the gridControl1_ResizingColumns event.


private void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
   //To unhide the column after dragging it to hide
   if(e.Reason == GridResizeCellsReason.MouseUp)
      int left = e.Columns.Left;
      GridControlBase grid = sender as GridControlBase ;
      if(left == e.Columns.Right && left < grid.Model.ColCount&& 
                                                   grid.Model.Cols.Hidden[left + 1])
         e.Cancel = true;
         grid.Model.Cols.Hidden[left + 1] = false;
         grid.Model.ColWidths[left + 1] = e.Width - grid.Model.ColWidths[left];


Private Sub gridControl1_ResizingColumns(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs) Handles gridControl1.ResizingColumns
   'To unhide the column after dragging it to hide
    If e.Reason = GridResizeCellsReason.MouseUp Then
      Dim left As Integer = e.Columns.Left
      Dim grid As GridControlBase = TryCast(sender, GridControlBase)
      If left = e.Columns.Right AndAlso left < grid.Model.ColCount AndAlso     grid.Model.Cols.Hidden(left + 1) Then
         e.Cancel = True
         grid.Model.Cols.Hidden(left + 1) = False
         grid.Model.ColWidths(left + 1) = e.Width - grid.Model.ColWidths(left)
      End If
    End If
End Sub



When you want Excel-like behavior to show the vertical split when the columns are hidden, you can achieve this by implementing your own mouse controller.

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/WF-14480-How_to_resize_the_hidden_columns255647687.zip

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