asp.net.ph

DataColumnCollection.CollectionChanged Event

System.Data Namespace   DataColumnCollection Class


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

[ VB ]
Public Event CollectionChanged As CollectionChangeEventHandler

[ C# ]
public event CollectionChangeEventHandler CollectionChanged;

[ C++ ]
public: __event CollectionChangeEventHandler* CollectionChanged;

[ JScript ] In JScript, you can handle the events defined by a class, but you cannot define your own.

Event Data

The event handler receives a CollectionChangeEventArgs containing data related to the CollectionChanged event. The following CollectionChangeEventArgs properties provide information specific to this event.

Property Description
Action Gets an action that specifies how the collection changed.
Element Gets the instance of the collection with the change.

Remarks

The Contains and CanRemove methods can be used to determine if a column exists and can be removed.

Example

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

private void AddHandler ( DataTable myTable ) {
   DataColumnCollection cols=myTable.Columns;
   cols.CollectionChanged += 
      new System.ComponentModel.CollectionChangeEventHandler (
      DataColumnCollection_Changed );
}
          
private void DataColumnCollection_Changed ( object sender,
   System.ComponentModel.CollectionChangeEventArgs e ) {
   DataColumnCollection cols= ( DataColumnCollection ) sender;
   Response.Write ( "DataColumnCollectionChanged: " + cols.Count );
}
See Also

DataColumnCollection Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph