Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 225637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:25:59+00:00 2026-05-11T19:25:59+00:00

My question has two parts: 1) How can I search for a sentence (e.g.,

  • 0

My question has two parts:

1) How can I search for a sentence (e.g., Dell Canada) in a string (e.g., I am working in Dell Canada, and I found it…) .

2)The second part is my string is text in a RichTextBox, so I would like to find the TextRange of that selected sentence and apply certain decoration.

thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:25:59+00:00Added an answer on May 11, 2026 at 7:25 pm

    The first part is pretty simple as CK has pointed out.
    Rich text formatting is dictated by certain predefined codes as defined in the RTF specification.
    First get the underlying RTF raw string from the control using the RTF property

    string rawString = richTextBox.Rtf;

    For eg: the rtf for the phrase ‘hello Bobby’ will look like this. It is something like HTML, you have tags which define the formatting.

    "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 hello Bobby\\par\r\n\\par\r\n}\r\n"
    

    Now suppose I want to make the phrase bold, I would set the Rtf property by replacing the string with

    "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17
    \\b hello Bobby\\par\r\n\\par\r\n}\r\n"
    

    Note the \\b before the phrase. That’s the code to make a given text bold.

    To perform this formatting using code, find the string you want to format(using the first technique) and insert the rtf code in the required position.
    Hope this helps.

    For the codes refer MSDN http://msdn.microsoft.com/en-us/library/aa140277.aspx

    PS: Jeff’s version is the easy one. This verison gives you infinite control. If you can do something in WordPad, you can do the same using rtf codes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question has two parts. Part 1. Yesterday I had some code which would
This question actually has two parts. The first part: I've been developing my first
My question has two parts. First one is: How can I include the background
This question has two parts. The collection structure is: _id: MongoID, agent_id: string, result:
My question has two parts: Is it possible that, if a segfault occurs after
The question has two parts, one of which I already have the answer for.
This question has two parts (maybe one solution?): Sample vectors from a sparse matrix
My question has two parts regarding haproxy. Question 1: The service that I am
My question has two parts: Does anyone have any tips or references to some
I have a two part question: Part 1 I have a module that has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.