DataView.ListChanged 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
發生於清單受 DataView 變更管理時。
public:
virtual event System::ComponentModel::ListChangedEventHandler ^ ListChanged;
public event System.ComponentModel.ListChangedEventHandler? ListChanged;
public event System.ComponentModel.ListChangedEventHandler ListChanged;
[System.Data.DataSysDescription("DataViewListChangedDescr")]
public event System.ComponentModel.ListChangedEventHandler ListChanged;
member this.ListChanged : System.ComponentModel.ListChangedEventHandler
[<System.Data.DataSysDescription("DataViewListChangedDescr")>]
member this.ListChanged : System.ComponentModel.ListChangedEventHandler
Public Custom Event ListChanged As ListChangedEventHandler
事件類型
實作
- 屬性
範例
下列範例會為 ListChanged 的事件 DataView新增處理程式。
public void CreateDataView(DataTable table)
{
DataView view = new DataView(table, "",
"ContactName", DataViewRowState.CurrentRows);
view.ListChanged += new
System.ComponentModel.ListChangedEventHandler(
OnListChanged);
}
private void OnListChanged(object sender,
System.ComponentModel.ListChangedEventArgs args)
{
Console.WriteLine("ListChanged:");
Console.WriteLine("\table Type = " + args.ListChangedType);
Console.WriteLine("\tOldIndex = " + args.OldIndex);
Console.WriteLine("\tNewIndex = " + args.NewIndex);
}
Public Sub CreateDataView(table As DataTable)
Dim view As New DataView(table, "", _
"ContactName", DataViewRowState.CurrentRows)
AddHandler view.ListChanged, _
New System.ComponentModel.ListChangedEventHandler( _
AddressOf OnListChanged)
End Sub
Private Sub OnListChanged(sender as Object, _
args As System.ComponentModel.ListChangedEventArgs)
Console.WriteLine("ListChanged:")
Console.WriteLine(vbTab & " Type = " & args.ListChangedType)
Console.WriteLine(vbTab & "OldIndex = " & args.OldIndex)
Console.WriteLine(vbTab & "NewIndex = " & args.NewIndex)
End Sub