RichTextBox control Undo

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nilam2477
    New Member
    • Feb 2008
    • 38

    RichTextBox control Undo

    I have RichTextBox control. I want to save the text in a stack for Undo operation each time user changes/updates the Text.
    I dont to want to use TextBox Base Undo functionality bec i have other controls whose state also would be saved in the same stack.
    If i use TextChanged event it occurs on each character typed. I dont want this. I also tried using RichTextBox.Lea ve event but this works only if control leaves the TextBox.
    I want to save the Text in the stack on following scenarios
    1. User selects already typed text and changes it
    2. User deletes the Text and types again etc
    Basically it should work like how the Undo works in Ms Word when you type in some text.
    Your suggestion is really appreciated. Please help
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You could still use the textchanged event, but in the event your would do some comparisons on what is typed and decide if you need to push the value onto your stack or not.
    You may also want to watch the keypress events to trigger on certain keypresses.
    Or use the selectionchange event.

    Comment

    Working...