Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataColumnCollection.CollectionChanged Event


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Occurs when the columns collection changes, either by adding or removing a column.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public event CollectionChangeEventHandler CollectionChanged

Use the Contains and CanRemove methods to determine whether a column exists and can be removed.

The following example adds an event handler for the CollectionChanged event.

private void AddEventHandler(DataTable table)
    DataColumnCollection columns = table.Columns;
    columns.CollectionChanged += new 

private void ColumnsCollection_Changed(object sender, 
    System.ComponentModel.CollectionChangeEventArgs e)
    DataColumnCollection columns = 
        (DataColumnCollection) sender;
    Console.WriteLine("ColumnsCollectionChanged: " 
        + columns.Count);

.NET Framework
Available since 1.1
Return to top
© 2018 Microsoft