PropertyValueChangedEventArgs.OldValue 屬性

定義

格子項目在被更改前的價值。

public:
 property System::Object ^ OldValue { System::Object ^ get(); };
public object OldValue { get; }
public object? OldValue { get; }
member this.OldValue : obj
Public ReadOnly Property OldValue As Object

屬性值

一個代表該財產舊值的物件。

範例

以下程式碼範例展示了此成員的使用方式。 在這個例子中,事件處理者會回報事件 PropertyGrid.PropertyValueChanged 的發生情況。 此報告能幫助您了解事件發生時間,並協助除錯。 若要報告多個事件或頻繁發生的事件,請考慮將MessageBox.Show訊息替換Console.WriteLine為或附加於多行TextBox

要執行範例程式碼,請將其貼到包含一個 PropertyGrid 名為 PropertyGrid1的實例的專案中。 然後確保事件處理程式與事件 PropertyGrid.PropertyValueChanged 相關聯。

private void PropertyGrid1_PropertyValueChanged(Object sender, PropertyValueChangedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ChangedItem", e.ChangedItem );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "OldValue", e.OldValue );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "PropertyValueChanged Event" );
}
Private Sub PropertyGrid1_PropertyValueChanged(sender as Object, e as PropertyValueChangedEventArgs) _ 
     Handles PropertyGrid1.PropertyValueChanged

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "ChangedItem", e.ChangedItem)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "OldValue", e.OldValue)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"PropertyValueChanged Event")

End Sub

備註

此房產會提供變更前房產的價值。 你可以透過查詢帶有指定 ChangedItem的屬性網格來找到新值。

適用於