In a Windows Forms application I would like to edit plain text (formatting is currently not required) but keep some parts of the text non-editable. E.g. start with “ABC” to which the user may append or prepend additional text or delete “ABC” entirely but always keep “ABC” as a non-editable atom.
My first thought was to use a RichTextBox and add an RTF field ({\field...}) but it seems like RichTextBox does not support fields.
Another approach could be to add the non-editable text as a picture. However, I have not found a way to reliably prevent resizing the image. (Question asked here before: Remove the ability to resize an image pasted into a richtextbox and add an event to that image. C#)
Do you have any suggestions how to get this to work using the fields or pictures? Or any other approach to design the desired behaviour?
My solution for the problem: Insert the text as an image using IRichEditOle. This way the text is treated like a single character which is exactly what I wanted. http://www.codeproject.com/KB/edit/MyExtRichTextBox.aspx explains how to use IRichEditOle.