PC Review


Reply
Thread Tools Rate Thread

DataTable: ColumnChanged event always fired

 
 
Anthony
Guest
Posts: n/a
 
      20th May 2004
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
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      20th May 2004
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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
detect ColumnChanged event "earlier" Ryan Liu Microsoft C# .NET 1 24th Feb 2008 07:00 PM
Calling Web Service in DragDrop event causes event to be fired multipletimes Vincent Mouton Microsoft Dot NET Framework Forms 0 18th Mar 2005 07:28 PM
DataTable.Add(row) and fired events Chris Alm Microsoft ADO .NET 1 26th Oct 2004 02:21 PM
ColumnChanged Event and GetChanges WineNCheese Microsoft ADO .NET 1 17th Apr 2004 09:51 PM
datacolumn.expression and columnchanged event Dominique Vandensteen Microsoft VB .NET 0 10th Feb 2004 10:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:17 PM.