473,385 Members | 1,766 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,385 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 4666
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.