Export (0) Print
Expand All

DataGridViewColumnCollection.IList.Insert Method

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Inserts an element into the collection at the specified index.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

void IList.Insert(
	int index,
	Object value
)

Parameters

index
Type: System.Int32

The zero-based index at which value should be inserted.

value
Type: System.Object

The Object to insert. The value can be null.

Implements

IList.Insert(Int32, Object)

ExceptionCondition
InvalidCastException

value is not a DataGridViewColumn.

ArgumentNullException

value is null.

InvalidOperationException

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:

-or-

The column indicated by value already belongs to a DataGridView control.

-or-

The SortMode property value of the column indicated by value is Automatic and the DataGridView.SelectionMode property value is FullColumnSelect or ColumnHeaderSelect. Use the control ISupportInitialize.BeginInit and ISupportInitialize.EndInit methods to temporarily set conflicting property values.

-or-

The InheritedAutoSizeMode property value of the column indicated by value is ColumnHeader and the DataGridView.ColumnHeadersVisible property value is false.

-or-

The column indicated by value has an InheritedAutoSizeMode property value of Fill and a Frozen property value of true.

-or-

The column indicated by value has a FillWeight property value that would cause the combined FillWeight values of all columns in the control to exceed 65535.

-or-

The column indicated by value has DisplayIndex and Frozen property values that would display it among a set of adjacent columns with the opposite Frozen property value.

-or-

The DataGridView control contains at least one row and the column indicated by value has a CellType property value of null.

This member is an explicit interface member implementation. It can be used only when the DataGridViewColumnCollection instance is cast to an IList interface.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft