hi everyone i need bit of support in my vb coding. i've publish data onto a datagrid(in vb express 2010). i just want to highlight entire row once the search data is found(in lime color) and color should be remain in that particular row when searching next records. so that user would easily know which records are searched and which are not by looking @ the color. any help. thanks in advance.

Recommended Answers

All 2 Replies

See if this helps.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        searchDGV(TextBox1.Text)
    End Sub
    Sub searchDGV(ByVal selSearch As String)
        With DataGridView1
            Dim iTemp As Integer = 1
            If .AllowUserToAddRows Then iTemp = 2 '// check if extra row or not, at bottom of dgv.
            For i As Integer = 0 To .Rows.Count - iTemp '// loop thru all rows.
                For x As Integer = 0 To .Columns.Count - 1 '// loop thru all columns in a row.
                    If .Item(x, i).Value = selSearch Then '// locate your search.
                        .Rows(i).DefaultCellStyle.BackColor = Color.Lime
                    End If
                Next
            Next
        End With
    End Sub

Thanks code order. i managed to find a solution and your solution seems rather easy to use. great :)

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.