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 8122241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:46:14+00:00 2026-06-06T05:46:14+00:00

Public Sub textcolorchanged() Dim searchword As String = RichTextBox2.Text.ToString.Trim Dim index1 As Integer =

  • 0
Public Sub textcolorchanged()
    Dim searchword As String = RichTextBox2.Text.ToString.Trim

    Dim index1 As Integer = 0

    While index1 <> -1
      If (index1 < ORGFILETXT.Text.Length) Then
        index1 = ORGFILETXT.Find(searchword, index1, RichTextBoxFinds.None)
        'If (index1 <= ORGFILETXT.TextLength) Then
            If index1 <> -1 Then
                ORGFILETXT.SelectionStart = index1
                ORGFILETXT.SelectionLength = searchword.Length
                ORGFILETXT.SelectionColor = Color.Red
                index1 = index1 + searchword.Length
            End If
        'End If

      Else
          index1 = -1
      End if
    End While
End Sub

I searched word of datagridview1 rows and highlighted search word in rich text-box. text(it is having total text)
I called this method in datagridview1 mouse click and key-up and key down event

word is highlighted in rich text-box.text when I mouse click and key up and key down on datagridview1 rows of search word but some time getting full text is changed color how???
pls help me

  • 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-06T05:46:17+00:00Added an answer on June 6, 2026 at 5:46 am

    Reading the documentation of RichTextBox.Find Method (String, Int32, RichTextBoxFinds) I have the suspect that, if the string is not found the return value is negative, but not -1.
    If this is the case then it’s possible that your code fails in setting the selection color.

    You could try to change this line

    If index1 <> -1 Then 
    

    with

    If index1 >= 0 Then 
    

    See also the their example in MSDN

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

Sidebar

Related Questions

Public Sub cleanTables(ByVal prOKDel As Short) Dim sqlParams(1) As SqlParameter Dim sqlProcName As String
Public Sub EdgeColor_Click() Dim intInFile As Integer intInFile = FreeFile Open c:\picturename.csv For Output
Public Sub WriteTextFile(ByVal SourceToWrite As String, ByVal LocationToWrite As String) Dim file As System.IO.StreamWriter
Public Sub BinarySearch_Surname(ByVal BrownieArray() As Brownie_Structure, ByVal SearchItem As String, ByVal LowInt As Integer,
I have the following code: <TestMethod()> _ Public Sub GetDirectoryEntryTest() Dim path As String
Public Sub MyFunction() Dim lowstring As String lowstring = hi Me.RichTextView.Find(lowstring, 0, 2) End
sample.vb class sam public shared sub hh() Console.WriteLine(asasas) end sub end class test.vb Dim
I've got the following code: Public Delegate Sub SetStatusBarTextDelegate(ByVal StatusText As String) Private Sub
Public Enum Fruit Red_Apple = 1 Oranges Ripe_Banana End Enum Private Sub InitCombosRegular() Dim
Using this in VB 2010: Imports System.Text.RegularExpressions Public Class Form1 Private Sub Button1_Click(ByVal sender

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.