You must Sign In to post a response.

How to compare the gridview cells in datagridview control in windows app

HI all,

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....


#522644    Author: swathi  30 Jun 2010 Member Level: Gold   Points : 2

can u explain clearly...which values u want to compare with datagridview cell values...?


#522648    Author: sarayu  30 Jun 2010 Member Level: Gold   Points : 2


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.

#522667    Author: swathi  30 Jun 2010 Member Level: Gold   Points : 2

check it 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")
Exit Sub
End If
'adds rows to datagridview
dgv_view.Rows.Add(True, rid, purpose)
End If
End Sub

This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.