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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:04:13+00:00 2026-06-02T01:04:13+00:00

I have a dataGridView that has 3 columns: SystemId, FirstName, LastName that is bound

  • 0

I have a dataGridView that has 3 columns: SystemId, FirstName, LastName that is bound using database information. I would like to highlight a certain row, which I would do using:

dataGridView1.Rows[????].Selected = true;

The row ID I however do not know and the bindingsource keeps changing, thus row 10 could be “John Smith” in one instance but not even exist in another (I have a filter that filters out the source based on what user enters, so typing in “joh” would yield all rows where first / last name have “joh” in them, thus my list can go from 50 names to 3 in a click).

I want to find a way how I can select a row based on SystemId and a corresponding number. I can get the system ID using the following method:

systemId = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["SystemId"].Value.ToString();

Now I just need to apply it to the row selector. Something like dataGridView1.Columns[“SystemId”].IndexOf(systemId} but that does not work (nor does such method exist). Any help is greatly appreciated.

  • 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-02T01:04:15+00:00Added an answer on June 2, 2026 at 1:04 am

    This will give you the gridview row index for the value:

    String searchValue = "somestring";
    int rowIndex = -1;
    foreach(DataGridViewRow row in DataGridView1.Rows)
    {
        if(row.Cells[1].Value.ToString().Equals(searchValue))
        {
            rowIndex = row.Index;
            break;
        }
    }
    

    Or a LINQ query

    int rowIndex = -1;
    
    DataGridViewRow row = dgv.Rows
        .Cast<DataGridViewRow>()
        .Where(r => r.Cells["SystemId"].Value.ToString().Equals(searchValue))
        .First();
    
    rowIndex = row.Index;
    

    then you can do:

    dataGridView1.Rows[rowIndex].Selected = true;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView that's bound to a DataSet. It has columns DateCreated, Weight,
I have a DataGridView bound to a DataTable that has 1+16 columns defined as
I have a datagridview that I have put a ContextMenuStrip1 on. I would like
I have a DataGridView that I would like all values on a specific row
I have a form created which an unbound datagridview that has three columns. Position,
I have a DataGridView that has three read only columns in it and one
I have a datagridview that is linked to a three columns in the database,
I have a Winforms app that has a DataGridView that is databound at runtime.
I have a DataGridView in a Winforms app that has about 1000 rows (unbound)
I have a DataGridView that I want to query using Linq (C# WinForm). 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.