すべての DataTable オブジェクトをコレクションから削除します。
Public Sub Clear()
[C#]
public void Clear();
[C++]
public: void Clear();
[JScript]
public function Clear();
解説
特定の DataTable をコレクションから削除するには、 Remove メソッドを使用します。
使用例
[Visual Basic, C#, C++] DataSet の DataTableCollection を取得し、コレクションからすべてのテーブルを消去する例を次に示します。
Private Sub ClearTables()
Dim myDataSet As DataSet
Dim tablesCol As DataTableCollection
' Get the DataSet of a DataGrid control.
myDataSet = CType(DataGrid1.DataSource, DataSet)
tablesCol = myDataSet.Tables
' Clear the collection.
tablesCol.Clear
End Sub
[C#]
private void ClearTables()
{
DataSet myDataSet;
DataTableCollection tablesCol;
// Get the DataSet of a DataGrid control.
myDataSet = (DataSet)DataGrid1.DataSource;
tablesCol = myDataSet.Tables;
// Clear the collection.
tablesCol.Clear();
}
[C++]
private:
void ClearTables()
{
DataSet* myDataSet;
DataTableCollection* tablesCol;
// Get the DataSet of a DataGrid control.
myDataSet = dynamic_cast<DataSet*>(DataGrid1->DataSource);
tablesCol = myDataSet->Tables;
// Clear the collection.
tablesCol->Clear();
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: 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
参照
DataTableCollection クラス | DataTableCollection メンバ | System.Data 名前空間