Dear All,
I have a problem when I want to active check validate primary key value in DataGridView.
EX : I have a DataTable with ID is Primary Key Column.
When I stay at Add Mode, I deliberate to input duplicate value or wrong ID's value and then i move previous row, this new row is remove (or delete). This thing is similar when i stay at Edit Mode, it returns the origrinal value.
My target is active check validate such as : show my message "Duplicate Value" or "This value is not valid".
If possible, give me sample project (VS.NET 2005) to solve my problem.
Thanks for your cooperation.

Validate (Primary Key Constrain) for DataGridView
lildan
JeromeGab
You can also use the RowValidating event and perform your validating there. The nice thing about RowValidating is that this event occurs when you move to a different row, but not while you are in the same row.
One important difference is that canceling RowValidating event will not keep the cell in edit mode, but canceling CellValidating does keep the cell in edit mode.
-mark
DataGridview Program Manager
Microsoft
This post is provided "as-is"