Hi Steve,
thinking about this issue a little further, i think your specific situation
should be handled by creating a unique constraint in the database itself. I
would especially not recommend validating duplicate db values at the ui
layer. you may want to check your design before moving forward.
as far as handling the datagrid events though...
you would create a handler for whichever event you wanted to catch. since
you seem to want to validate the data in the gridcell i would recommend the
DataGridColumnStyle.TextBox.Validating (you won't find this in intellisense,
but keep typing, it's there) event for this. Just my personal preference,
there are other ways such as suggested. by George Shepards winforms faq.
in your form load you could add some code like this...
\\\
AddHandler tb1.TextBox.Validating, me.myValidatingProcedure
///
the addhandler statement points the event to the actual procedure that will
perform the validation for you. Keep in mind that this procedure must
receive in the same parameters that the event is passing when raised.
\\\
private sub myValidatingProcedure(byval sender as object, byval e as
System.ComponentModel.EventArgs)
dim entryIsValid as boolean = 'code to validate what is is you need to
validate here...
if (not entryIsValid)
e.Cancel 'this line invalidates the control and causes focus to
return the focus
end if
end sub
///
hope this helps,
jim