DataGridViewColumnCollection.RemoveAt(Int32) Method

Definition

Removes the column at the given index in the collection.

C#
public virtual void RemoveAt(int index);

Parameters

index
Int32

The index of the column to delete.

Exceptions

index is less than zero or greater than the number of columns in the control minus one.

The associated DataGridView control is performing one of the following actions that temporarily prevents new columns from being added:

  • Selecting all cells in the control.

  • Clearing the selection.

  • Updating column DisplayIndex property values.

-or-

This method is being called from a handler for one of the following DataGridView events:

Remarks

To remove a column that is automatically generated when binding to a data source, call this method in a DataGridView.DataBindingComplete event handler.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also