473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to format a string before appending it into a RichTextBox? Is it possible?

I`m inserting strings in a rich text control using the AppendText method, I
would like to change certain parts of the string so, for example, a certain
word appears bold and red when inserted. Is it possible using this control?

Thanks,
Juan.
Nov 16 '05 #1
2 4668
Juan wrote:
I`m inserting strings in a rich text control using the AppendText method, I
would like to change certain parts of the string so, for example, a certain
word appears bold and red when inserted. Is it possible using this control?


Yes, here's an example:

richTextBox.SelectionStart = richTextBox.TextLength;
richTextBox.SelectionColor = Color.Red;
richTextBox.SelectedText = "Red text." + Environment.NewLine;
richTextBox.SelectionColor = Color.Blue;
richTextBox.SelectedText = "Blue text."
Nov 16 '05 #2
Thanks C# Learner, got it.

Juan.


"C# Learner" <cs****@learner.here> escribió en el mensaje
news:#o**************@TK2MSFTNGP12.phx.gbl...
Juan wrote:
I`m inserting strings in a rich text control using the AppendText method, I would like to change certain parts of the string so, for example, a certain word appears bold and red when inserted. Is it possible using this
control?
Yes, here's an example:

richTextBox.SelectionStart = richTextBox.TextLength;
richTextBox.SelectionColor = Color.Red;
richTextBox.SelectedText = "Red text." + Environment.NewLine;
richTextBox.SelectionColor = Color.Blue;
richTextBox.SelectedText = "Blue text."

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CNU | last post by:
Hi, I have a richtextbox control that displays some xml data either by loading from a file or by copy-paste in plaintext format. So, it is displayed without any formatting or indentation. Now,...
2
by: Juan | last post by:
I`m inserting strings in a rich text control using the AppendText method, I would like to change certain parts of the string so, for example, a certain word appears bold and red when inserted. Is...
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...
10
by: D Steward | last post by:
I can't seem to add a newline (/n) to get a richtextbox control to display text on successive lines. The text that I type is overwritten. How do I remedy this My example richTextBox->Multiline...
11
by: Noozer | last post by:
I have the following Subs defined to place text into a richtextbox with a specific font and colour, depending on context. Occasionally, the font just doesn't get applied and the text appears in the...
8
by: **Developer** | last post by:
ControlRichTextBox1.SelectedText = String.Format("{0} {1}", strExt, x.szTypeName) & vbCrLf Three questions: 1) How can I insert a tab between {0} and (1} so the richtextbox tabs...
4
by: AWesner | last post by:
For readability sake I’m going to first state that: LF = Line Feed CHR(10) CR = Carriage Return CHR(13) Since Rich Text Format is a standard formalized by Microsoft Corporation I get to ask...
3
by: khalid Ahmed | last post by:
Hi, can any one help me how to append string into richtextBox with a specific font, highlight color but does not change the previous text style. so if you have any ideas plz help me... thanks...
7
by: Tom | last post by:
Hi all, I am looking for a smart way to assure a file is indeed a text file within a C# method and not binary. For example: Will "thisMysteryFile.dat" be legible if opened in a RichTextBox...
4
by: =?Utf-8?B?Y2xhcmE=?= | last post by:
Hi all, It may sound esoteric, but actually it is. Let's say there is a string resource in a project, the value is "AA BB". How can I only format the "BB" part into bold type. Can I finish the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.