Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!

I have a RichTextBox control. I use it for syntax highlighting in my text.

The problem is: after a syntax is highlighted, when user press Ctrl+Z (calls Undo action)... control "unhighlights" my text.

For highlighting I use Select method and SelectionColor property. How to suppress writting actions into the undo stack of a RichTextBox during SelectionColor changes? Is it possible?work.


What I have tried:

I tried using the LockCurrentUndoUnit method on the highlight logic to solve this problem, but it did not work.
Posted
Updated 12-Jan-19 12:25pm

Rather than lock it delete the formatting undo unit triggered by a "spacebar" key down event before it gets buried requiring you dig/parse the undo pool. There might be a way to set up the undo tracking to omit the inclusion of formatting as well --been a while for me. Best wishes.
 
Share this answer
 
Set the UndoLimit property of your Textbox to 0 or IsUndoEnabled to False... Should work.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900