Hi guys about my previous post on Copy Selected rows from Datagrid to another that was answered by oussama_1 and Deep Modi, I was wodering if is it possible to detect that there is a similar row between the 2 Datarids to avoid redundancy? Does it require a datatable or dataset?

Recommended Answers

All 2 Replies

Additional info: After it detects a duplicate the user will have an option to replace the old row with a new row? Example:

'DataGridView1: Item List

id item       order
1  bleach     5       '<--------Edited Value




'DataGridView1: Order List

id item       order
1  bleach     3       '<--------Old Value

After editing in DataGridView1, the system will prompt the user if they want to replace the existing order in DataGridView2 with the value in DataGridView1. I'm using CellEndEdit event for this.

        For indx = 0 To DataGridView2.Rows.Count - 1
            If DataGridView1.CurrentRow.Cells("ID").Value = DataGridView2.Rows(indx).Cells(1).Value Then
                Dim ask = MessageBox.Show("Record Already Exist, Replace existing record ?", "Records", _
                                          MessageBoxButtons.YesNoCancel)
                If ask = DialogResult.Yes Then
                    ''copy code
                End If
            Else
                ''copy code
            End If
        Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.