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

  • Home
  • SEARCH
  • 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 8557341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:33:10+00:00 2026-06-11T15:33:10+00:00

After importing a text file into my Windows Form Application Rich Text box, I

  • 0

After importing a text file into my Windows Form Application Rich Text box, I now want to add the search function. Is it possible to have multiple SelectionStart values? The SelectionLength will be the same seeing that its the same word.

        string textfield = TextField.Text;
        string searchword = searchbox.Text;
        int found=0;
        TextField.SelectionLength = searchword.Length;
        TextField.SelectionBackColor = Color.LightBlue;

        for (int y = 0; y < textfield.Length; y++)//Goes through whole string
        {
            if (searchword[0] == textfield[y])//Looks for first character
            {
                for (int x = 0; x < searchword.Length; x++)//Checks if rest of  characters match
                {
                    if (searchword[x] == textfield[y + x])
                    {
                        found++;
                    }
                    else
                        break;
                }
            }

            if (found == searchword.Length)
            {
                TextField.SelectionStart = y;//////Want to have multiple of these
            }
            found=0;
        }
        TextField.Focus();
  • 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-06-11T15:33:11+00:00Added an answer on June 11, 2026 at 3:33 pm

    No you can’t. But you can change the back color of a selected text, for example. Start by selecting a word. Then do this

    foreach (Match match in matches) {
        richTextBox.SelectionStart = match.Index;
        richTextBox.SelectionLength = match.Length;
        richTextBox.SelectionBackColor = Colors.Yellow;
    }
    

    To clear the all the markings, just select the whole text and set the back color to white (assuming that you are not using back colors otherwise).

    In the example I am assuming that you are using Regex. You would find the words with:

    string pattern = String.Format(@"\b{0}\b", Regex.Escape(wordToFind));
    MatchCollection matches = Regex.Matches(richTextBox.Text, pattern);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 1GB sql text file I'm importing into MySQL. I've used a
I made the mistake of modifying my original source after importing it into subversion.
My application running android ice cream sandwich, after importing roboto.ttf and roboto-bold.ttf fonts in
I'm importing text in from an xml file and i'm using htmlText to try
I am importing data from a text file and have hit a snag. I
I decided to try to preprocess function text before it's compilation into byte-code and
So the file I am importing into a ListBox looks like this (each newline
I am trying to import a CSV file into my PHP application built with
I am reading a text file into a database through EF4. This file has
After importing content from a legacy website using the Feeds module, I'm left with

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.