DataSet.HasChanges and Textbox.TextChanged Event

G

Guest

I have been banging my head against this one and I'm sure I'm missing
something:

Got a WinForms app in VB.NET with controls bound to a dataset. For the sake
of this discussion, let's use just one text box control. When the user makes
changes, the first character change in the text box will not set the
underlying DataSet.HasChanges to true. Only the subsequent character change
sets the DataSet.HasChanges to true. Why is that?

More importantly, here is what I need to do:

I need to give the user visual feedback that the record in the dataset is
'dirty' as soon as the user makes the first change. More importantly, if the
user changes only ONE single character, the DataSet.HasChanges needs to be
true so that the rest of my verification and validation code works and I can
prompt the user to save if there are changes that have to be yet written back
to the database table.

How can I do that?

Thanks,

JB
 
C

Cor Ligthert

JBSound,

First what you tell seems to me impossible.

Data is pushed in the dataset by a change of the current row.

That is why when by instance a button acts as the start for an update, the
first thing that must be done is an endcurrentedit.

So when you want to do what you want, you need something as do everytime
when there is a value change in your textbox an encurrentedit.

I am afraid that your user will not be happy because of the strange effect
it probably has.( I did not thest it).

I hope this helps something.

Cor
 
G

Guest

Thanks for your time responding. However, I disagree with you on your
assessment that this is not possible. I have this working with some issues
that still need to be addressed.

To further clarify:

I use the TextChanged event of the text box to see if the dataset has
changes. However, as I have found out in the mean time, that's not
necessarily the place to check, or at least not with the EndCurrentEdit
method of the BindingContext for the dataset. Problem there is that
TextChanged happens before the dataset gets updated. So I have to find
another way of pulling this off.

The other aspect of that is that if a TextChange event occurred, the dataset
would already be different, unless that change is cancelled.

Thanks for your attempt to help!

JB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top