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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:47:36+00:00 2026-05-26T15:47:36+00:00

I have a data grid view in one windows form named GridViewForm. When the

  • 0

I have a data grid view in one windows form named “GridViewForm”. When the user search for the text from the search box from another window form named “FindForm”, I want to highlight all the matching result in the data grid view. The search type can be exact or partial.

For eg.

If the user search for the text “stack”, then the words “stack” from [Stack, stack-over, stacks, stack exchange] should be highlighted and first cell that match the query should be selected. When the user press next button then another cell that match the search query should be selected.

My code for finding the text is like follow for it search only the exact word.

        Dim gridRow As Integer = 0
        Dim gridColumn As Integer = 0
        For Each Row As DataGridViewRow In AccountsDataGridView.Rows
            For Each column As DataGridViewColumn In AccountsDataGridView.Columns
                If TryCastString(AccountsDataGridView.Rows(gridRow).Cells(gridColumn).Value).ToLower = SearchTextBox.Text.ToLower Then
                    'AccountsDataGridView.Rows(intcount).Cells(0).Value = "0"
                    MsgBox("FOUND") 'Should be highlight insted of showing message and the cell should be select.
                End If
                gridColumn += 1
            Next column
            gridColumn = 0
            gridRow += 1
        Next Row

Is there any way to implement my concept? I am using vb.net windows form. Thanks in advance.

  • 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-26T15:47:37+00:00Added an answer on May 26, 2026 at 3:47 pm

    Well you could set the cell’s background color with a different color to highlight all the matches, and select only the cell corresponding to the current match:

    Dim searchIndex = 0
    AccountsDataGridView.ClearSelection()
    For Each row As DataGridViewRow In AccountsDataGridView.Rows
        For each cell As DataGridViewCell in row.Cells
            If CStr(cell.Value).Contains(SearchTextBox.Text, StringComparison.OrdinalIgnoreCase) Then
                If searchIndex = m_CurrentSearchIndex Then
                    'This is the cell we want to select
                    cell.Selected = True
                End If
                'Yellow background for all matches
                cell.Style.BackColor = Color.Yellow
                searchIndex += 1
            End If
        Next
    Next
    

    If m_CurrentSearchIndex has a value of 0, it would select the first match, second match for a value of 1, etc.

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

Sidebar

Related Questions

In VB.net 3.5 SP1 I have a Windows Form with three DataGridView controls. One
I have a Data Grid View inside a control that is displayed in a
Imagine that in one data template, I have a textBox, and another data template,
I have a SQLite database that is displayed in a data grid view in
I have data grid view with columns product name and product image and I
I have a Data Grid View and some of the columns are of type
I Have a bound Data grid view to the below Questions Class: public class
I have three column in my datagridview .One is text ,one is Combo and
I have a DataGridView which is filling from Table in SQL Server Database. One
how to add the checkbox to the datagridview from coding in windows form. i

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.