指定したインデックス位置にある行をコレクションから削除します。
Public Sub RemoveAt( _
ByVal index As Integer _)
[C#]
public void RemoveAt(intindex);
[C++]
public: void RemoveAt(intindex);
[JScript]
public function RemoveAt(
index : int);
パラメータ
- index
削除する行のインデックス。
解説
行を削除すると、その行にあるすべてのデータが失われます。 DataRow クラスの Delete メソッドを呼び出すと、行に削除マークだけを付けることができます。 RemoveAt を呼び出すことは、 Delete を呼び出してから AcceptChanges を呼び出すことと同等です。
Clear メソッドを使用して、コレクションのすべてのメンバを一度に削除することもできます。
使用例
[Visual Basic] RemoveAt メソッドを呼び出して DataRowCollection 内の最後の行を削除する例を次に示します。
Private Sub RemoveRowByIndex()
Dim myTable As DataTable
Dim rc As DataRowCollection
Dim foundRow As DataRow
myTable = CType(DataGrid1.DataSource, DataTable)
rc = myTable.Rows
If rc.Count = 0 Then Exit Sub
rc.RemoveAt( rc.Count - 1)
End Sub
[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
DataRowCollection クラス | DataRowCollection メンバ | System.Data 名前空間 | Clear | Add