DataColumnCollection.CollectionChanged Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when the columns collection changes, either by adding or removing a column.
public:
event System::ComponentModel::CollectionChangeEventHandler ^ CollectionChanged;
public event System.ComponentModel.CollectionChangeEventHandler? CollectionChanged;
public event System.ComponentModel.CollectionChangeEventHandler CollectionChanged;
member this.CollectionChanged : System.ComponentModel.CollectionChangeEventHandler
Public Custom Event CollectionChanged As CollectionChangeEventHandler
Event Type
Examples
The following example adds an event handler for the CollectionChanged event.
private void AddEventHandler(DataTable table)
{
DataColumnCollection columns = table.Columns;
columns.CollectionChanged += new
System.ComponentModel.CollectionChangeEventHandler(
ColumnsCollection_Changed);
}
private void ColumnsCollection_Changed(object sender,
System.ComponentModel.CollectionChangeEventArgs e)
{
DataColumnCollection columns =
(DataColumnCollection) sender;
Console.WriteLine("ColumnsCollectionChanged: "
+ columns.Count);
}
Private Sub AddEventHandler(table As DataTable)
Dim columns As DataColumnCollection = table.Columns
AddHandler columns.CollectionChanged, _
AddressOf ColumnsCollection_Changed
End Sub
Private Sub ColumnsCollection_Changed _
(sender As Object, e As System.ComponentModel. _
CollectionChangeEventArgs)
Dim columns As DataColumnCollection = _
CType(sender, DataColumnCollection)
Console.WriteLine("ColumnsCollectionChanged: " _
& columns.Count.ToString())
End Sub
Remarks
Use the Contains and CanRemove methods to determine whether a column exists and can be removed.
Applies to
Συνεργαστείτε μαζί μας στο GitHub
Μπορείτε να βρείτε την πηγή για αυτό το περιεχόμενο στο GitHub, όπου μπορείτε επίσης να δημιουργήσετε και να εξετάσετε ζητήματα και αιτήματα έλξης. Για περισσότερες πληροφορίες, ανατρέξτε στον οδηγό συνεργατών.