473,498 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4672
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
2028
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
658
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
15884
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
11599
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
1392
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
10479
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
6499
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
1450
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
1937
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
3973
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
7125
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
7002
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
7203
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...
0
5462
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
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.