469,957 Members | 2,676 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,957 developers. It's quick & easy.

RichTextBox and font change

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.

Oct 22 '06 #1
1 3503
Vivien,

Try this link:
http://www.codeproject.com/cs/miscct...oxextended.asp
This isa good place to find examples http://www.codeproject.com

Hope that helps

MikeY

"Vivien Parlat" <po****@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
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.

Oct 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Michael A. Covington | last post: by
2 posts views Thread by Hariharan S | last post: by
1 post views Thread by sunrise | last post: by
9 posts views Thread by James Wong | last post: by
2 posts views Thread by =?Utf-8?B?TWFyayBDb2xsYXJk?= | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.