New to Telerik UI for WinForms? Download free 30-day trial

Column Events

In this article we discuss RadGridView events related to its columns:

AutoGeneratingColumn

When you set RadGridView's AutoGenerateColumns property to True (the default value), RadGridView creates a column for each public property of the bound objects and the AutoGeneratingColumn event is triggered for each of those columns.

You can use the following properties of the GridViewAutoGeneratingColumnEventArgs class:

  • Cancel: Setting this to True cancels the creation of the current column.

  • Column: The column that is being generated.

The following example demonstrates how you can cancel the creation of a specific column:

private void RadGridView1_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
{
    if (e.Column.HeaderText  == "CreationDate")
    {
        e.Cancel = true;
    }
}


Private Sub RadGridView1_AutoGeneratingColumn(ByVal sender As Object, ByVal e As GridViewAutoGeneratingColumnEventArgs)
    If e.Column.HeaderText = "CreationDate" Then
        e.Cancel = True
    End If
End Sub

Changing the DataType property of the column will not be respected in the AutoGeneratingColumn event handler.

CurrentColumnChanged

This event will be triggered when the CurrentColumn property is changed. Through the CurrentColumnChangedEventArgs of its event handler you can access the following:

  • CurrentColumn: Gets the current column.

  • NewColumn: Gets the new column.

ColumnWidthChanging

A ColumnWidthChanging event occurs when you resize a column programmatically or through the UI.

You can resize columns only if AllowColumnResize is set to True (which is the default value).

Through the ColumnWidthChangingEventArgs of its event handler you can access the following:

  • Cancel: Setting this to True cancels the resizing of the current column.

  • Column: The column that is being resized.

  • ColumnIndex: Gets the index of the column whose width is changing.

  • NewWidth: Gets or sets the new width for the column.

If you cancel ColumnWidthChanging, the column's width does not change and the ColumnWidthChanged event is not triggered.

ColumnWidthChanged

The ColumnWidthChanged event occurs after the resize of a column is complete. It also triggers when the user double-clicks the header cell gripper to resize the column to fit its content.

You can access the following properties of the ColumnWidthChangedEventArgs object:

  • ColumnIndex: Gets the index of the column whose width is changing.

ColumnChooserCreated

The ColumnChooserCreated event occurs when a column is hidden and added to the column chooser form.

You can access the following properties of the ColumnChooserCreatedEventArgs object:

  • ColumnChooser: Gets or sets the GridViewColumnChooser form.
In this article