DataGridViewRowCollection.IList.Add(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将 DataGridViewRow 添加到集合。
virtual int System.Collections.IList.Add(System::Object ^ value) = System::Collections::IList::Add;
int IList.Add (object value);
int IList.Add (object? value);
abstract member System.Collections.IList.Add : obj -> int
override this.System.Collections.IList.Add : obj -> int
Function Add (value As Object) As Integer Implements IList.Add
参数
返回
新 DataGridViewRow 的索引。
实现
例外
value
不是 DataGridViewRow。
关联的 DataGridView 控件正在执行以下操作之一,该操作暂时禁止添加新行:
选择控件中的所有单元格。
清除所选内容。
- 或 -
正在从以下 DataGridView 事件之一的处理程序调用此方法:
- 或 -
DataGridView 的 DataSource 属性不是 null
。
- 或 -
DataGridView 没有列。
- 或 -
value
的 DataGridView 属性不是 null
。
- 或 -
value
具有 true
的 Selected 属性值。
- 或 -
此操作将在未冻结行之后添加一个冻结行。
value
为 null
。
value
包含的单元格比控件中的列多。
注解
此方法是显式接口成员实现。 它只能在 DataGridViewRowCollection 实例被强制转换为 IList 接口时使用。
此方法调用 Add(DataGridViewRow) 重载,在 value
将重 DataGridViewRow载强制转换为 后传入。
添加新行时,控件中的行不会自动排序。 若要将新行排序到正确的位置,请在事件处理程序中DataGridView.RowsAdded调用 DataGridView.Sort 方法。 你可能还希望在事件处理程序中CellValueChanged调用 DataGridView.Sort 方法,以在用户修改单元格时对行进行排序。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈