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.ShowConsole.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属性网格来查找新值。

适用于