DataRowCollection.InsertAt(DataRow, Int32) 方法

定義

將新的資料列插入集合的指定位置。

public:
 void InsertAt(System::Data::DataRow ^ row, int pos);
public void InsertAt (System.Data.DataRow row, int pos);
member this.InsertAt : System.Data.DataRow * int -> unit
Public Sub InsertAt (row As DataRow, pos As Integer)

參數

row
DataRow

要加入的 DataRow

pos
Int32

集合中要加入 DataRow 的 (以零起始) 位置。

例外狀況

pos 小於 0。

備註

InsertAt 指定的位置會以唯一 DataRowCollection 的數據列順序反映。 如果在陣列中傳回一個 DataRow 以上的資料列,則插入的數據列可能不會傳回所 InsertAt指定的位置。 例如, Rows 屬性會傳回指定插入位置中的數據列。 SelectGetChildRows 不一定。 例如,當您將 的內容 DataRowCollection 寫入為 XML 時, WriteXml數據列會根據 所 DataRowCollection指定的順序來寫入。

如果為 pos 參數指定的值大於集合中的數據列數目,則會將新的數據列加入結尾。

適用於