472,976 Members | 1,229 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,976 software developers and data experts.

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 3616
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael A. Covington | last post by:
When you change the Font property of a RichTextBox, does it change the font of all the contents, or only the text subsequently added, or only the selection, or what?
2
by: Hariharan S | last post by:
Hi Guys, I have a string, say "Hello World" and would like to format the way I want to (say, wanna have the Hello to be bold italic and the World to be of font size 14 or so) and put it in the...
4
by: Du | last post by:
I want to format the text within my richtextbox. However I have large amount of text to change, simply using richtextbox.select and format is not pratical. How do I change text format using...
0
by: y2k692hu | last post by:
Hello I am trying to run this and I keep getting a "SystemNullReferenceException: Object reference not set to instance of an object" error. I have three menu items bold, italic and underline. When i...
0
by: Matt | last post by:
This took way to long to figure out - now that I have it working I thought I would share with the group. I've seen tons of posts with very little good answers on this seemingly simple thing that...
1
by: sunrise | last post by:
I've been playing around the RichTextBox and reading a few articles, in order to create a text editor like Notepad++ in C#. To be frank, I'm very disappointed by the RichTextBox control...
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
2
by: =?Utf-8?B?TWFyayBDb2xsYXJk?= | last post by:
I'm currently writing an application that has a RichTextBox and a toolbar which includes the following toolbar buttons: - Font - Font Size - Bold - Italic - Underline I want the toolbox...
1
by: Andrus | last post by:
I need to save font selected by user by Ctrl+MouseWheel in Winforms RichTextBox. I tried override below but this does not remember font: in this method Font.Size property seems to be always...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.