DataGridViewColumnCollection.IList.Insert(Int32, Object) 方法

定义

在集合中的指定索引处插入一个元素。

 virtual void System.Collections.IList.Insert(int index, System::Object ^ value) = System::Collections::IList::Insert;
void IList.Insert (int index, object value);
void IList.Insert (int index, object? value);
abstract member System.Collections.IList.Insert : int * obj -> unit
override this.System.Collections.IList.Insert : int * obj -> unit
Sub Insert (index As Integer, value As Object) Implements IList.Insert

参数

index
Int32

应插入 value 的从零开始的索引。

value
Object

要插入的 Object。 该值可以为 null

实现

例外

valuenull

关联的 DataGridView 控件正在执行以下操作之一,该操作暂时禁止添加新列:

  • 选择控件中的所有单元格。

  • 清除所选内容。

  • 更新列 DisplayIndex 属性值。

- 或 -

正在从以下 DataGridView 事件之一的处理程序调用此方法:

- 或 -

value 指示的列已属于 DataGridView 控件。

- 或 -

value 指示的列的 SortMode 属性值为 Automatic,且 SelectionMode 属性值为 FullColumnSelectColumnHeaderSelect。 使用该控件的 ISupportInitialize.BeginInit()ISupportInitialize.EndInit() 方法可暂时设置冲突的属性值。

- 或 -

value 指示的列的 InheritedAutoSizeMode 属性值为 ColumnHeader,且 ColumnHeadersVisible 属性值为 false

- 或 -

value 指示的列的 InheritedAutoSizeMode 属性值为 Fill,且 Frozen 属性值为 true

- 或 -

value 指示的列的 FillWeight 属性值会导致控件中所有列的组合 FillWeight 值超过 65535。

- 或 -

value 指示的列的 DisplayIndexFrozen 属性值会在具有相反的 Frozen 属性值的一组相邻列中显示它。

- 或 -

DataGridView 控件至少包含一行,且 value 指示的列的 CellType 属性值为 null

注解

此成员是显式接口成员的实现。 它只能在 DataGridViewColumnCollection 实例被强制转换为 IList 接口时使用。

适用于

另请参阅