DataGridViewCellCollection.Add(DataGridViewCell) 方法

定义

将单元格添加到集合。

public:
 virtual int Add(System::Windows::Forms::DataGridViewCell ^ dataGridViewCell);
public virtual int Add(System.Windows.Forms.DataGridViewCell dataGridViewCell);
abstract member Add : System.Windows.Forms.DataGridViewCell -> int
override this.Add : System.Windows.Forms.DataGridViewCell -> int
Public Overridable Function Add (dataGridViewCell As DataGridViewCell) As Integer

参数

dataGridViewCell
DataGridViewCell

要添加到集合的 A DataGridViewCell

返回

插入新元素的位置。

例外

拥有此权限 DataGridViewCellCollection 的行已属于控件 DataGridView

-或-

dataGridViewCell 已经属于一个 DataGridViewRow

注解

在将行添加到DataGridViewRow控件之前,使用此方法填充DataGridView单元格。 将行添加到控件后,它包含的单元格数始终与控件中的列数匹配,因此此方法不再有用。

适用于

另请参阅