Here I want to compare the cell values in the datagridview for duplicates and need to show a message...
i am using datagridview control in windows application...
Please help me....
can u explain clearly...which values u want to compare with datagridview cell values...?
The scenario is i want to enter new value in the grid and i have some previous rows in the same grid and now i want to check for duplicates which i have entered newly with previous row values.
check it once...here i have two cols in gridview id and purpose..
i am adding new values to gridview when add button is clicked..
Private Sub btn_Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Add.Click
chkmandatory() 'calling function to check mandatory fields
If mandatory <> 1 Then
'getting entered values into local variables
rid = txt_RequisitionId.Text.Trim
purpose = txt_Purpose.Text.Trim
For row1 As Integer = 0 To dgv_view.Rows.Count - 1
'if entered requistionid and itemid is already added then exit sub
If rid = dgv_view.Item(1, row1).Value.ToString Then
msgbox( "Item is already added")
'adds rows to datagridview
dgv_view.Rows.Add(True, rid, purpose)