Monday, July 4, 2016

Search from DataGridView VB.NET

        Dim i As Integer = 0
        Dim rcount As Integer = 0
        Dim ifound As Boolean = False

        Try
            rcount = DataGridView1.RowCount
            DataGridView1.MultiSelect = False

            While i < rcount And ifound = False
                DataGridView1.Rows(i).Selected = True

                If DataGridView1.SelectedRows(0).Cells(1).Value = TextBox10.Text Then
                    DataGridView1.CurrentCell = DataGridView1(0, i)
                    ifound = True

                else
                    i = i + 1
                End If

                

            End While
        Catch ex As Exception
            MessageBox.Show(ex.Message, "found")
        End Try

        If ifound = False Then MessageBox.Show("no record found", "")

No comments: