none
search in 3 datagridview RRS feed

  • Question

  • I have 3 DatagridView and TextBox I want when setting the value by searching and selecting the search in 3 data 

    What is required to search for a specific value in the 3 Data Grid View? Provided they are in the same column? / And not under the condition that it be in the same row

    Sunday, November 12, 2017 11:46 PM

Answers

  • Hi ahmeddc,

    You want to search data from three datagridview control, if the value you want to search in the same column in three datagridview, you can only search from one column in datagridview, if the value may appear in any one column, you can search in the entire datagridview.

    Search from a column in datagridview.

     For i As Integer = 0 To DataGridView1.Rows.Count - 1
                    If DataGridView1.Rows(i).Cells("Column1").Value = TextBox1.Text Then
                        DataGridView1.Rows(i).Selected = True
                    End If
                Next
                'datagridview2
                'datagridview3

    Search from the entire datagridview

    For i As Integer = 0 To DataGridView1.RowCount - 1
                    For j As Integer = 0 To DataGridView1.ColumnCount - 1
                        DataGridView1.Rows(i).Cells(j).Value = TextBox1.Text
                        DataGridView1.Rows(i).Selected = True
                    Next
                Next
                'datagridview2
                'datagridview3

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ahmeddc Monday, November 13, 2017 4:24 AM
    Monday, November 13, 2017 2:57 AM
    Moderator