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 発生を報告します。 このレポートは、イベントが発生したタイミングを確認するのに役立ち、デバッグに役立ちます。 複数のイベントまたは頻繁に発生するイベントを報告するには、 を Console.WriteLine に置き換えるかMessageBox.Show、複数行TextBoxにメッセージを追加することを検討してください。

コード例を実行するには、 という名前PropertyGrid1の型PropertyGridのインスタンスを含むプロジェクトに貼り付けます。 次に、イベント ハンドラーがイベントに関連付けられていることを確認します 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を使用してプロパティ グリッドに対してクエリを実行すると、新しい値を見つけることができます。

適用対象