Finding a specific DataGridView Row based off of "Find"?

BlakeMcKenna used Ask the Experts™
I know in DataTables you can perform a "Find" based off of a PrimaryKey. Can something similar be done for a DataGridView without having to loop through all the rows? I am basically trying to find an "equipment_ID" based on a value from a variable.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Normally, the DataGridView is displaying a DataTable or other source of data, and you would search that. Is there a reason that won't work for you? Is the issue that you want to select the matching row or something like that? What I've done is select a cell in the row with the correct number, such as:
        Dim dvNumbers As DataView
        dvNumbers = dsSet.dtEqpt.DefaultView
        dvNumbers.Sort = "equipment_ID"
        dgvNumbers.DataSource = dvNumbers
        Dim intMatch as Integer
        intMatch = dvNumbers.Find("ABCDE")
        dgvNumbers.CurrentCell = dgvNumbers.Item(0, intMatch)

Open in new window


Thank you...that's what I was looking for!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial