Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to prevent textbox becomes dirty by giving focus

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hello,
I have in my textbox in gotfocusmethod (a custom property):
this.uOldValue = this.Value

That way the old value is always there if I'd like to revert.
But I found that once the control gets focus this makes the control dirty.
I trigger on dirty controls (dirty = fldstate has changed) to save pending alterations. As I also ask for confirmation to the user prior to do the actual save this always triggers the confirmation. Even if no real change was there.

Is there a way to exclude such a property from making the control dirty?

TIA
-Bart
 
Bart,

Are you sure about this? You are saying that executing this.uOldValue = this.Value causes GETFLDSTATE() to show the field has changed?

That doesn't make sense to me. GETFLDSTATE() looks at the contents of the field in the buffer. It is not directly related to the control. In any case, reading the value of a control (as opposed to writing to it) shouldn't change the field.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike,
You are right.Problem seems not to be caused by the control.
This happened in a delete-record method on my data-form.
The main datasource is a view which I requery after the save-data method.
There was an fault in my code. I did not save the position of the recordpointer. So also did not a reposition if no confirmation for save for received.

Still strange that if I temporarily removed that
this.uOldValue = this.Value
No problem occurred.

Anyway problem is solved.

KR
-Bart
 
Bart,

I don't understand this any more than you do, but I'm glad the problem's solved.

For what it's worth, I generally use OLDVAL() and EVALUATE() to detect dirty fields, rather than GETFLDSTATE(). The advantage is that it doesn't give a false positive if the user edits a field and then edits it back to its original value.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi Mike,
Thank for your feedback.
I'm with you that oldval() and eveluate() makes more sense in this case. In my framework I integrated a save-form based upon the general save-form method as described in 1001 things. In my controls I usually have a setfldstate to correct the state if the old and current value don't differ.
For that I do have "this.uOldValue = this.Value" in my gotfocus method. I am also using the oldvalue to put things back once the user exits the control using ESC-key.

-Bart
 
Bart,

For that I do have "this.uOldValue = this.Value" in my gotfocus method.

If the table is buffered, you don't need to do that. The OLDVAL() function will automatically give you the original value.

I am also using the oldvalue to put things back once the user exits the control using ESC-key.

Doesn't that happen automatically as well?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top