0

I want to develop a file viewing program for a specific read-only file format and for the most part it will just be scrollable text. The ultra-simple way is of course to use an existing text display controls, but I've come to the conclusion that I want a graphical sort of "custom colored highlighting", text coloring, and maybe other things painted in. So I was planning to handle the painting myself. I take it that attempting to line up my own graphics on top of a label or rich text box would be a bad idea, so I was planning to just paint everything except the scroll bar... unless these labels/rich text controls are a lot more extensible in some way that I don't know about?

Assuming I go the painting route, I'm not 100% sure of the specifics. Do I paint directly into a Panel? Or is there a better GUI control to paint into? Also, I think it will be better if I don't buffer the screen because I think repainting the contents on validation will be easy/efficient... but repainting from a buffer might be even faster... will it save me a lot of trouble if I just have a screen buffer... is this significantly inefficient? Is my plan of painting directly into a Panel, unbuffered, a good idea or is there a preferred method that I'm passing up?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
VoidStar
  • 5,241
  • 1
  • 31
  • 45
  • Have you considered using the RichTextBox? http://stackoverflow.com/questions/2527700/change-color-of-text-within-a-winforms-richtextbox – JDB Dec 23 '12 at 05:48
  • You could still paint "things" on top of the RichTextBox... it would just save you a lot of trouble to have the text handled for you. (See [GetPositionFromCharIndex](http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.getpositionfromcharindex.aspx) to help you get started) – JDB Dec 23 '12 at 05:52
  • Thanks, the existence of GetPositionFromCharIndex implies that they've thought through the use case of painting atop the RichTextBox, and tells me where to position my drawing, so I'll try overriding OnPaint for a RichTextBox. – VoidStar Dec 23 '12 at 18:55

1 Answers1

0

Try to use WebBrowser control orRichTextBox (make formatted html or rtf from your text).

Ria
  • 10,237
  • 3
  • 33
  • 60