DataGridViewColumnCollection.Item[] Property

Definition

Gets or sets a column in the collection.

Overloads

Item[String]

Gets or sets the column of the given name in the collection.

Item[Int32]

Gets or sets the column at the given index in the collection.

Item[String]

Source:
DataGridViewColumnCollection.cs
Source:
DataGridViewColumnCollection.cs
Source:
DataGridViewColumnCollection.cs

Gets or sets the column of the given name in the collection.

C#
public System.Windows.Forms.DataGridViewColumn this[string columnName] { get; }
C#
public System.Windows.Forms.DataGridViewColumn? this[string columnName] { get; }

Parameters

columnName
String

The name of the column to get or set.

Property Value

The DataGridViewColumn identified by the columnName parameter.

Exceptions

columnName is null.

See also

Applies to

.NET Framework 4.8.1 and other versions
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

Item[Int32]

Source:
DataGridViewColumnCollection.cs
Source:
DataGridViewColumnCollection.cs
Source:
DataGridViewColumnCollection.cs

Gets or sets the column at the given index in the collection.

C#
public System.Windows.Forms.DataGridViewColumn this[int index] { get; }

Parameters

index
Int32

The zero-based index of the column to get or set.

Property Value

The DataGridViewColumn at the given index.

Exceptions

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

See also

Applies to

.NET Framework 4.8.1 and other versions
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