DataColumnCollection.CollectionChanged DataColumnCollection.CollectionChanged DataColumnCollection.CollectionChanged DataColumnCollection.CollectionChanged Event


열을 추가하거나 제거하여 열 컬렉션이 변경되는 경우 발생합니다.Occurs when the columns collection changes, either by adding or removing a column.

 event System::ComponentModel::CollectionChangeEventHandler ^ CollectionChanged;
public event System.ComponentModel.CollectionChangeEventHandler CollectionChanged;
member this.CollectionChanged : System.ComponentModel.CollectionChangeEventHandler 
Public Custom Event CollectionChanged As CollectionChangeEventHandler 


다음 예제에서는 CollectionChanged 이벤트에 대 한 이벤트 처리기를 추가 합니다.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);
 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. _

     Dim columns As DataColumnCollection = _
        CType(sender, DataColumnCollection)
     Console.WriteLine("ColumnsCollectionChanged: " _
        & columns.Count.ToString())
End Sub


사용 된 ContainsCanRemove 열 있고 제거할 수 있는지 여부를 결정 하는 방법입니다.Use the Contains and CanRemove methods to determine whether a column exists and can be removed.

적용 대상