468,513 Members | 1,763 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

DataTable: ColumnChanged event always fired

Hi,

When I update a datatable through a datagrid the ColumnChanged event
is fired. In this event I check if the new value that the user has
entered is correct and change it if it's not. My problem is when I
change it, the ColumnEvent is fired again. How can I prevent this? I
thought BeginEdit would do the trick but it doesn't seem to work.

I thought of using 'RemoveHandler' and 'AddHandler' but I'm fairly
sure there is a proper solution.

Any suggestions?

Anthony.

Simplified code (if I put 'e.Row.BeginEdit()' or not, it doesn't make
any difference):

Private Sub MyDataTable_ColumnChanged(ByVal sender As Object,
ByVal e As System.Data.DataColumnChangeEventArgs) Handles
MyDataTable.ColumnChanged
If e.Column.ColumnName = "Col1" Then
If e.ProposedValue.ToString.Trim.Length > 0 Then
If e.ProposedValue = "test" Then
e.Row.BeginEdit()
e.Row("Col1") = "test2" 'This fires the event
again
e.Row.EndEdit()
End If
Else
e.Row.CancelEdit()
End If
End If
End Sub
Nov 20 '05 #1
1 2405
Hi Anthony,

Why not only make a togle boolean swicth in that procedure

If it is true, it comes back and you can than only set it to false and after
that exit the procedure.

Cor
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Christopher W. Douglas | last post: by
2 posts views Thread by Cesar Ronchese | last post: by
9 posts views Thread by jeff | last post: by
reply views Thread by Ryan Liu | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.