다음을 통해 공유


DataColumnCollection.CollectionChanged 이벤트

정의

열을 추가하거나 제거하여 열 컬렉션이 변경되는 경우 발생합니다.

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 

이벤트 유형

예제

다음 예제에서는 CollectionChanged 이벤트에 대한 이벤트 처리기를 추가합니다.

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

설명

CanRemove 메서드를 Contains 사용하여 열이 존재하고 제거할 수 있는지 여부를 확인합니다.

적용 대상