$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Data Grid WinForms Control
Create data gird view in C# with modern user interface for your Windows Forms applications
Home > WinForms UI Controls > User Manual > Resize Grid Columns in C#

Column Resizing in C#

The Kettic Data Grid control provides the support of column resizing to hold data. It is really easy to adjust the width of columns by dragging the column vertical grid line to desired size with mouse and then release your drag. If users of the Data Grid Control do not need resize the columns, they can easily disable the functionality in the Grid user interface for all columns by setting the property ApplyColumnResize to false or for a specific column by setting the property ApplyResize to false.

Resize Columns in C#

It is possible for users to change the column width for a particular one. No matter how narrow the width of the column is, it is able to hold some data. The Data Grid column offers the property Width to users to resize column. Furthermore, the two values, MinimumWidth and MaximumWidth, allow users to restrict the length of data for column. The following C# code snippet shows how to resize column.

this.ketticGrid.Columns["Picture"].Width = 120;

Size Column Automatically

To size the column for data grid columns, users can use each of the two properties to achieve this, the SizeColumnAuto and AutoFit. The SizeColumnAuto property is able to fill the entire grid with columns by setting it to DataGridSizeColumnAuto.Fill. The AutoFit property is used to fit the grid with content columns. It requires each of the two methods, DataGridTemplate.AutoFitColumn or DataGridTemplate.AutoFit and can be performed by applying the context menu of the header cell and double click of the header edge.

SizeColumnAuto Customizing

The SizeColumnAuto property has various options available to customize the columns as specific requirements.
  • AutoFitColumn.None, this mode is able to disable the AutoFitColumn property and won’t allow the width automatic change.
  • AutoFitColumn.EntireCells, this mode is able to adjust the column width to fit the entire cells of contents in Data Grid Control
  • AutoFitColumn.ShownDataCells, this mode is able to adjust the column width to fit the contents of data cells that has been shown.
  • AutoFitColumn.HeaderCells, this mode is able to adjust the column width to fit the contents of the header cell.
  • AutoFitColumn.FilterCells, this mode is able to adjust the column width to fit the filter cell contents
  • AutoFitColumn.SymmaryRowCells, this mode is able to adjust the column width to fit the summary row cell contents
  • AutoFitColumn.SystemCells, this mode is able to adjust the column width to fit the system cells contents
  • AutoFitColumn.ShownCells, this mode is able to adjust the column width to fit the shown cells contents

Events of Resizing Columns

The Kettic Data Grid Control offers the support of column resizing, which will fire the ColumnWidthChanging event when resizing the columns and will fire the ColumnWidthChanged when the resizing process completed.
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls