DataTableCollection.Clear メソッド

定義

すべての DataTable オブジェクトのコレクションをクリアします。

public:
 void Clear();
public void Clear();
member this.Clear : unit -> unit
Public Sub Clear ()

次の例では、DataTableCollectionDataSetを取得し、すべてのテーブルのコレクションをクリアします。

private void ClearTables()
{
    // Get the DataSet of a DataGrid control.
    DataSet dataSet = (DataSet)DataGrid1.DataSource;
    DataTableCollection tables = dataSet.Tables;

    // Clear the collection.
    tables.Clear();
}
Private Sub ClearTables()
   ' Get the DataSet of a DataGrid control.
   Dim dataSet As DataSet = CType(DataGrid1.DataSource, DataSet)
   Dim tables As DataTableCollection = dataSet.Tables

   ' Clear the collection.
   tables.Clear
End Sub

注釈

コレクションから特定の DataTable を削除するには、 Remove メソッドを使用します。

適用対象