i want to search for an item in a datagrid view via a textbox .. so i type something in the textbox like the product name .. and he finds it ..
i use visual studio 2010 and access database

Recommended Answers

All 2 Replies

You can scan through the rows with a For Each, then scroll to the row (if found). An example is

For Each row As DataGridViewRow In DataGridView1.Rows
    If row.Cells(1).Value = txtName.Text Then
        row.Selected = True
        DataGridView1.FirstDisplayedScrollingRowIndex = row.Index
        Exit For
    End If
Next

abdalqader.abdelhalem according to your post you are using ms access to fill the datagridview, I will assume (and I hate to do that) you are filling a datatable and using it as the source for the DataGridView. Why not query the datatable for your string using LINQ. If the data you are searching for is in a single column of the table it is very easy and fast to get the row number.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.