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
的 Selected 屬性值為 true
。
-或-
這項作業會將凍結的資料列加在未凍結的資料列後面。
value
為 null
。
value
所包含的儲存格多於控制項中的資料行數目。
備註
這個方法是明確的介面成員實作。 只有在 DataGridViewRowCollection 執行個體轉換成 IList 介面時,才能使用這個成員。
這個方法會 Add(DataGridViewRow) 呼叫 多載,並將 value
它 DataGridViewRow 轉換成 之後傳入 。
新增資料列時,控制項中的資料列不會自動排序。 若要將新資料列排序為正確的位置,請在事件處理常式中 DataGridView.RowsAdded 呼叫 DataGridView.Sort 方法。 您也可以在事件處理常式中 CellValueChanged 呼叫 DataGridView.Sort 方法,以在使用者修改儲存格時排序資料列。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應