OriginalValue プロパティは編集モード中だけ有効です。このプロパティは、エディターが編集モードに再入するときにリセットされます。IsAlwaysInEditMode が True に設定されると、エディターがフォーカスを受け取る時に、OriginalValue もリセットされます。ユーザーがエディターに入る時は、原則的に OriginalValue プロパティは元の値を維持します。これは、ユーザーが編集作業をキャンセルする場合、オリジナル値に戻すために使用されます。
Private Sub Button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) ' When edit mode ends, the value will be committed and OriginalValue and ' HasValueChanged will be reset. Me.textEditor1.EndEditMode(True, False) Me.textEditor1.Value = "A" ' HasValueChanged and OriginalValue properties are only applicable during ' edit mode. These properties are set when the value of the editor is ' modified after entering edit mode. Me.textEditor1.StartEditMode() ' The following will print out 'A' and False respectively. Debug.WriteLine("After entering edit mode:") Debug.WriteLine("OriginalValue = '" & Me.textEditor1.OriginalValue & "'") Debug.WriteLine("HasValueChanged = " & Me.textEditor1.HasValueChanged) Me.textEditor1.Value = "B" ' The Value was modified to B above. The following will print out 'A' and ' True respectively. Debug.WriteLine("After changing value to B:") Debug.WriteLine("OriginalValue = '" & Me.textEditor1.OriginalValue & "'") Debug.WriteLine("HasValueChanged = " & Me.textEditor1.HasValueChanged) ' When edit mode ends, the value will be committed and HasValueChanged will ' be reset. Me.textEditor1.EndEditMode(True, False) ' The following will print out False. Debug.WriteLine("After exiting edit mode:") Debug.WriteLine("HasValueChanged = " & Me.textEditor1.HasValueChanged) End Sub
public void button1_Click( object sender, RoutedEventArgs e ) { // When edit mode ends, the value will be committed and OriginalValue and // HasValueChanged will be reset. this.textEditor1.EndEditMode( true, false ); this.textEditor1.Value = "A"; // HasValueChanged and OriginalValue properties are only applicable during // edit mode. These properties are set when the value of the editor is // modified after entering edit mode. this.textEditor1.StartEditMode( ); // The following will print out 'A' and False respectively. Debug.WriteLine( "After entering edit mode:" ); Debug.WriteLine( "OriginalValue = '" + this.textEditor1.OriginalValue + "'" ); Debug.WriteLine( "HasValueChanged = " + this.textEditor1.HasValueChanged ); this.textEditor1.Value = "B"; // The Value was modified to B above. The following will print out 'A' and // True respectively. Debug.WriteLine( "After changing value to B:" ); Debug.WriteLine( "OriginalValue = '" + this.textEditor1.OriginalValue + "'" ); Debug.WriteLine( "HasValueChanged = " + this.textEditor1.HasValueChanged ); // When edit mode ends, the value will be committed and HasValueChanged will // be reset. this.textEditor1.EndEditMode( true, false ); // The following will print out False. Debug.WriteLine( "After exiting edit mode:" ); Debug.WriteLine( "HasValueChanged = " + this.textEditor1.HasValueChanged ); }