RichTextBox and font change

V

Vivien Parlat

Hello,

I'm trying to create a small text editor (to be included in another
project), and I've created two methods to toggle bold/italic/underlined
text styles, in order to have the same behaviour as WordPad has, ie :
if I select a text which has bold and non-bold parts, and click
"Italic", after that I have an italic-bold part and an italic-non-bold
one. This is not the case by default, and some programs I use don't
offer to do this.

My algorithm consists in moving the selection before each character,
isolating parts which have the same characteristic, and then use an
enhanced version of MSDN sample code to add or remove the style.

The point is, this takes time (on an Athlon XP 2200+...). If I have a
long selection, and make it bold, the user sees the cursor while it is
moving (to test "SelectedFont" attribute), and sees also the text
blocks being changed. So am I doing that the right way ? Isn't there a
better way to do it, or a way to disable RichTextBox graphical update
during the internal update ? Kind of a "BeginUpdate/EndUpdate", or
"DisablePaint/Repaint" pair, like for some double-buffer components
(when using OpenGL for example) ?

I use VC#2005, and .net framework 2.

Thanks in advance for any answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top