473,396 Members | 1,924 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,396 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 4667
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...

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.