Way to find out whether a Record in the form is changed or not ?

G

Guest

Is there any way to find out whether a record in the form is changed or not.
Say we are having a customer Form, where user can create or view customers.
When the user hits the Close/Exit icon, we want to find out whether the user
has done any changes or not ?
If there are changes, then we want to prompt the user to save them first. So
we want to set a flag whenever the user "Changes" any field in the record ,
so that we can identify whether a record is "Dirty" or not.

what are the alternatives ?

- Anand
 
C

Cor Ligthert

Anand,

That depends what is a record.

When it is a row from a datatable, than you can check if a datatable
"haschanges" and than check the "rowstate" of the datarows in that.

I hope this helps?

Cor
 
G

Guest

More clarification :

We are talking to the db in the following manner.
The ui fields will be converted as a customer object and passed on to our
dblayer, which will write the insert statements etc. We are not using
datatable or datarows in the VB form.
so,in this case, we want to write some code in the form, to set a flag
anytime the user has made any change to any field.
 
C

Cor Ligthert

Anand,

Than I think can be a solution to set first all your values to a hashtable
and check those using the names of the textboxes you use to the current
value when the user ends.

(In fact is this completly build in, in the datarow.rowstate.)

However just a thought because I never did it like this.

Cor
 
S

skOOb

I went through this when I first started vb.net. All I did was make
hidden labels with the same information off the screen and compared
those values when the user tried to exit (not the most efficient way,
but it works). That was when I didn't want to invest much time in
learning a faster way to do it. Cor's solution is probably much more
efficient.
 

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