RichTextBox Text Formating 
Author Message
 RichTextBox Text Formating

How can I manipulate the text formating of the text in a rich text box?
   I would like to be able to search for certain strings and then
display them in a bold font.  I've been looking for some examples, but
all the ones that I have found just link the text from an external file.
thanks


Mon, 06 Jun 2005 19:41:41 GMT  
 RichTextBox Text Formating
Hello,

You may find the target string via the Find method, and then set its style
by granting a new Font to this string. This is a sample code:

// Find the target string
String target = "test";
int start = richTextBox1.Find(target);

// Set the string to Bold style
richTextBox1.Select(start, target.Length);
richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont,
FontStyle.Bold);
richTextBox1.Select(0,0);

I hope this helps you.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.  2001 Microsoft Corporation. All rights
reserved.
--------------------

    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1)
Gecko/20021130
    X-Accept-Language: en-us, en
    MIME-Version: 1.0
    Subject: RichTextBox Text Formating
    Content-Type: text/plain; charset=us-ascii; format=flowed
    Content-Transfer-Encoding: 7bit
    Lines: 6

    Date: Thu, 19 Dec 2002 11:41:41 GMT

    NNTP-Posting-Date: Thu, 19 Dec 2002 03:41:41 PST
    Newsgroups: microsoft.public.dotnet.languages.CSharp
    NNTP-Posting-Host: vienna7.his.com 216.194.225.92
    Path:
cpmsftngxa09!TK2MSFTNGP08!TK2MSFTNGP09!vienna7.his.com!nntp1.roc.gblx.net!nn
tp.gblx.net!nntp.gblx.net!ngpeer.news.aol.com!news.maxwell.syr.edu!newspeer1
.nwr.nac.net!news.ticon.net!feed.news.sonic.net!typhoon.sonic.net!not-for-ma
il
    Xref: cpmsftngxa09 microsoft.public.dotnet.languages.csharp:117731
    X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

    How can I manipulate the text formating of the text in a rich text box?
       I would like to be able to search for certain strings and then
    display them in a bold font.  I've been looking for some examples, but
    all the ones that I have found just link the text from an external file.
    thanks



Fri, 10 Jun 2005 15:54:39 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. printf -- formating output text w variables

2. paste text formating

3. wrong text position in RichTextBox

4. Center text in a RichTextBox

5. Pasting into RichTextBox - formatting taxt pasted as text!

6. RichTextBox set text to bold/color

7. Appending RTF formatted text to a RichTextBox?

8. Tree node with RichTextBox as its Text member

9. Question on RichTextBox Control...Rtf or Text??

10. RichTextBox - clearing text

11. How to scroll text in the RichTextBox from code

12. escape sequence to add color text to richtextbox

 

 
Powered by phpBB® Forum Software