Export (0) Print
Expand All

DataColumnCollection.Clear Method

Clears the collection of any columns.

[Visual Basic]
Public Sub Clear()
[C#]
public void Clear();
[C++]
public: void Clear();
[JScript]
public function Clear();

Remarks

If the collection is successfully changed by adding or removing columns, the OnCollectionChanged event occurs.

Example

[Visual Basic, C#, C++] The following example clears the columns collection.

[Visual Basic] 
Private Sub ClearColumnsCollection(dt As DataTable)
    Dim cols As DataColumnCollection
    ' Get the DataColumnCollection from a DataTable in a DataSet.
    cols = dt.Columns
    cols.Clear()
End Sub

[C#] 

 private void ClearColumnsCollection(DataTable dt){
    DataColumnCollection cols;
    // Get the DataColumnCollection from a DataTable in a DataSet.
    cols = dt.Columns;
    cols.Clear();
 }

[C++] 

private:
 void ClearColumnsCollection(DataTable* dt){
    DataColumnCollection* cols;
    // Get the DataColumnCollection from a DataTable in a DataSet.
    cols = dt->Columns;
    cols->Clear();
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataColumnCollection Class | DataColumnCollection Members | System.Data Namespace

Show:
© 2015 Microsoft