Ryobi
Registered User.
- Local time
- Today, 16:08
- Joined
- Mar 5, 2012
- Messages
- 49
Hello,
I have this issue that perhaps somebody can solve using a gridataview in Vb,net. The column of cells need to be unique, so I am checking for duplicates when the cells are changed or added. If the cell are duplicates then I want to cell to be reverted to the old value. I have my code below
For Each row In DgvDataRecords.Rows
If ItemName = row.Cells("Card ID").Value Then
Itemcnt = Itemcnt + 1
If Itemcnt > 1 Then
' MessageBox.Show("Item already exists, can not be add. ")
DgvDataRecords.CurrentCell.Value = Oldvalue
Exit Sub
End If
If Itemcnt = 1 Then
Rowfound = DgvDataRecords.Rows.IndexOf(row)
End If
End If
Next
The code works except that I want to put a message to tell the user that the cells are duplicate. This the remarked line ' MessageBox.Show("Item already exists, can not be add. "). The problem that I have is that when the old value is restored the error message is displayed again as it was part the cell. Is there a way to suppress the second error message ?
Thank you
I have this issue that perhaps somebody can solve using a gridataview in Vb,net. The column of cells need to be unique, so I am checking for duplicates when the cells are changed or added. If the cell are duplicates then I want to cell to be reverted to the old value. I have my code below
For Each row In DgvDataRecords.Rows
If ItemName = row.Cells("Card ID").Value Then
Itemcnt = Itemcnt + 1
If Itemcnt > 1 Then
' MessageBox.Show("Item already exists, can not be add. ")
DgvDataRecords.CurrentCell.Value = Oldvalue
Exit Sub
End If
If Itemcnt = 1 Then
Rowfound = DgvDataRecords.Rows.IndexOf(row)
End If
End If
Next
The code works except that I want to put a message to tell the user that the cells are duplicate. This the remarked line ' MessageBox.Show("Item already exists, can not be add. "). The problem that I have is that when the old value is restored the error message is displayed again as it was part the cell. Is there a way to suppress the second error message ?
Thank you