Stephen

Stephen

  • NA
  • 8
  • 0

How do you convert Plain Text to Rich Text problem free?

Feb 6 2007 12:34 AM
Hi, I'm currently writing a simple text editor in Visual C# 2005 Express which has some syntax highlighting for the MIPS Assembly language. I use a RichTextBox control to color the keywords and it works so far, except for one problem: when I copy text from (or load in) a plain text source file, the text (using Currier New) is out of alignment in some places. In other words, the text is lined up correctly if you view it in notepad, but in my program it seems that anywhere there are tab characters everything is out of whack. Curiously, if you copy the same text into Word Pad, it has the same problem, even if you choose a non-variable width font like Currier New. I guess what I'm trying to say is copying a plain text file into RTF editors seems to have some formatting issues, where the plaintext source file looks fine in notepad but a bit out of whack in something like Word Pad. I'd just use a normal TextBox control (which works fine) if I didn't need to color the keywords! So the real question is, how can I get Rich Text formatting to behave more like plain text formatting, at least as far as tabs and alignment are concerned?

Answers (2)