0

I have a problem...

I need a VB code which validate cell (ID) - (I used event CellValidating),

this value must be unique in datagrid... and if this value of cell is uniqe, then sort rows in datagrid by the ID column.

Example, datagrid is:

ID          Name                
1           First
3           third

And if I enter in the ID value 3, then popup Messagebox.Show ("Error")...

But, if I enter value 2 in the column ID, then the datagrid must sort automatically

Is this good for sorting -> DataGridViewColumnSortMode.Automatic ??

Thanks

1 Answer 1

1

Should be able to use a simple If Then statement to get this done. This outline should get you going in the right direction.

If datagrid.ID = "your input" Then
msgbox("This ID already exhists")
ElseIf
'code to add to datagrid
'code to re-sort grid
EndIF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.