CodexArcanum
CodexArcanum

Reputation: 4016

Using a (Rich)TextBox as a window onto a larger buffer

I feel like I'm missing an obvious point here, but let's say I'm working on a text editor, and I'd like to store a file's (partial?) contents as a text buffer. My text buffer is some specialized data structure for holding lots of text, not just a simple string or StringBuilder. I'd also like to expose the text to the user, probably through a standard text box or rich text box.

What is the best means of doing this?

Would I copy a segment out of the buffer into the textbox, then adjust everything manually and copy changes back? Would I copy the entire buffer as a string into the textbox? If I was only loading part of a file into the buffer (to handle very large files) would I have to set up a second translation layer from buffer to file? Do I need an entirely different control from the built in textboxes to accomplish this?

EDIT: I'd also accept suggestions for 3rd-party text controls that would work well. My main block here is not wanting to build/learn/import the entirety of (for example) GTK or QT just to get a decent text editor control.

Upvotes: 1

Views: 673

Answers (2)

idstam
idstam

Reputation: 2878

I use a RichTextBox in logview4net as a window on whatever data I'm looking at. It is only forward scrolling and I can't really say I like it.

I think you're better off looking for some other editor control.

Upvotes: 1

Chris Meek
Chris Meek

Reputation: 5839

See the ebook referenced from this question, the sharpdevelop guys go into some detail on how to construct a text editor.

Upvotes: 1

Related Questions