You must Sign In to post a response.
  • Category: .NET

    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
    can u explain clearly...which values u want to compare with datagridview cell values...?

    Regards
    swathi

  • #522648
    Hi...

    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
    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
    clearvalues()
    '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
    Next
    '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.