Re: RowDeleting, RowChangeing, ColumnChanging exception handling by Val
Val
Tue Jun 01 17:13:22 CDT 2004
Hi,
What you need to do is to create events for the DataTable and catch all the
changes there. If DataGrid control is bound to the DataTable, then events
will fire for the DataTable as soon as DataGrid will try to change or
delete. Your code would look like
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
myDataTable = New DataTable("myDataTable")
AddHandler myDataTable.RowChanging, AddressOf myDataTable_Changing
End Sub
Protected Sub myDataTable_Changing(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs)
e.Row.CancelEdit()
End Sub
--
Val Mazur
Microsoft MVP
"?eljko Margeta" <zmargeta@hotmail.com> wrote in message
news:cc7b61c6.0406010855.3b6d427f@posting.google.com...
> As I figured out, the recomended way to cancel editing of a column, or
> deletion of a row is to create an event handler for ColumnChanging or
> RowDeleting events, and to throw your own exception. Well, I did just
> that, and the problem is that I do not know where to catch this
> exception. As I understand, it should be done somewhere in the
> DataGrid which is bound to the DataTable which raised an event, but I
> don't know where. Can anybody help me?