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

要加入至集合的 DataGridViewCell

傳回

Int32

要插入新元素的位置。

例外狀況

擁有這個 DataGridViewCellCollection 的資料列已經屬於 DataGridView 控制項。

-或- dataGridViewCell 已經屬於 DataGridViewRow

備註

在將資料列新增至 DataGridView 控制項之前,請使用這個方法 DataGridViewRow 填入儲存格。 將資料列加入控制項之後,它所包含的儲存格數目一律符合 控制項中的資料行數目,因此此方法不再有用。

適用於

另請參閱