473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 2614
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
6
by: Tom | last post by:
Hi, In the following code I have reproduced a problem in IE that is extremely annoying for my application. <html> <head> <script type="text/javascript">
7
by: Raymond Lewallen | last post by:
Which would be the proper way or the reason for using any of the following or combinations of the following? These are the 3 ways I've figured I can do what I want to do, I just don't know which...
2
by: Cesar Ronchese | last post by:
Hi All. I'm printing the contents of a datatable in my control, and actually it is working well. My problem is when a row is deleted from the datatable, which fires the RowDeleted event and,...
3
by: Ryan Liu | last post by:
Can someone give a sample to prevent a row from being deleted in a datatable? I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work. I need verify if there other data...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
0
by: Ryan Liu | last post by:
I have a DataGrid with only one column is editable. It is a DataGridViewCheckBoxColumn. I want to detect if the any checkbox state is changed. So I listen to ColumnChanged event. But whenever...
0
by: sammartin | last post by:
Hi, I've got a question which I'm hoping has a simple answer. I have a series of control bound to an underlying DataTable. The databinding are setup to update the data source on validation....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.