Groups | Blog | Home
all groups > dotnet windows forms databinding > june 2004 >

dotnet windows forms databinding : dataSet.HasChanges and TextChanged event


Steve
6/23/2004 1:18:17 PM
Hi all

I have been trying to find out what the problem is with the
dataSet.HasChanges property. It only seems to be updating the second time I
change something. I have done some tests and have seen that, if you call the
EndCurrentEdit for the data-binding and then call the HasChanges, it will
return false because I am calling the HasChanges from within the TextChanged
event of the TextBox, and the TextBox doesn't recognize a change in the
dataSet until the TextChanged event has been exited.
----------------------------------
Example code:
Private Sub ChangeTitleByVal sender As Object, ByVal e As System.EventArgs)
Handles txtTitle.TextChanged
DirectCast(BindingContext(m_oDataSet.Employees),
CurrencyManager).EndCurrentEdit()
Button2.Text = m_oDataSet.HasChanges.ToString <-- Will return False the
first change because we are still in the TextChanged event
End Sub
----------------------------------
Has anyone else come across this behaviour? Are there any other events that
I could use? Basically, I want a button to be Enabled after changes are made
to the data-bound controls, the change could only be 1 character in 1
control.

Kind regards,
Steve.

Ken Tucker [MVP]
6/26/2004 3:32:58 PM
Hi,

The currency manager has an itemchanged event. That event fires when
the user moves to a new record after making changes.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscurrencymanagerclassitemchangedtopic.asp

Ken
=====================

[quoted text, click to view]

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004

AddThis Social Bookmark Button