指定した DataTable オブジェクトをコレクションから削除します。
オーバーロードの一覧
指定した DataTable オブジェクトをコレクションから削除します。
.NET Compact Framework でもサポート。
[Visual Basic] Overloads Public Sub Remove(DataTable)
[JScript] public function Remove(DataTable);
指定した名前の DataTable オブジェクトをコレクションから削除します。
.NET Compact Framework でもサポート。
[Visual Basic] Overloads Public Sub Remove(String)
[JScript] public function Remove(String);
使用例
[Visual Basic, C#, C++] Contains メソッドと CanRemove メソッドを使用して、指定したテーブルが存在するかどうか、および削除できるかどうかを確認する例を次に示します。削除できる場合は、テーブルを削除するために Remove メソッドが呼び出されます。
[Visual Basic, C#, C++] メモ ここでは、Remove のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。
Private Sub RemoveTables()
' Set the name of the table to test for and remove.
Dim strName As String = "Suppliers"
' Presuming a DataGrid is displaying more than one table, get its DataSet.
Dim dSet As DataSet = CType(DataGrid1.DataSource, DataSet)
Dim tablesCol As DataTableCollection = dSet.Tables
If tablesCol.Contains(strName) _
And tablesCol.CanRemove(tablesCol(strName)) Then
tablesCol.Remove(strName)
End If
End Sub
[C#]
private void RemoveTables()
{
// Set the name of the table to test for and remove.
string strName = "Suppliers";
// Presuming a DataGrid is displaying more than one table, get its DataSet.
DataSet dSet = (DataSet)DataGrid1.DataSource;
DataTableCollection tablesCol = dSet.Tables;
if (tablesCol.Contains(strName) && tablesCol.CanRemove(tablesCol[strName]))
tablesCol.Remove(strName);
}
[C++]
private:
void RemoveTables()
{
// Set the name of the table to test for and remove.
String* strName = S"Suppliers";
// Presuming a DataGrid is displaying more than one table, get its DataSet.
DataSet* dSet = dynamic_cast<DataSet*>(DataGrid1->DataSource);
DataTableCollection* tablesCol = dSet->Tables;
if (tablesCol->Contains(strName) && tablesCol->CanRemove(tablesCol->Item[strName]))
tablesCol->Remove(strName);
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
参照
DataTableCollection クラス | DataTableCollection メンバ | System.Data 名前空間