Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP6SP5 - How to know that a txt.value has changed
Message
De
09/06/2003 11:32:34
 
 
À
09/06/2003 10:49:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00797581
Message ID:
00797982
Vues:
29
One more caveat, and then I'm done being the Grinch. If you use Menus or Toolbars, remember that if you click on a toolbar button or a menu item, they do not get focus, and so the LostFocus() of the control may not always fire when you'd expect it to. You might have to work around that issue. I usually check for changes all at once whenever the user wants to be done with the form.

Alan

>you're welcome. hope it helps
>>Thanks for a different approach.
>>
>>>This may be a bit late but... I had the same problem in an app a couple of years ago. I wanted to check the value of a control at lostfocus to see if it was the same as the value originally assigned. In the init i copied the value to the controls tag propery and checked against that value on exit from the control. I added a numeric tag property to create an nTextBox for numeric values and a date tag for date boxes. I didn't want to check field state as it won't tell you if the value has been changed back to the original. There is curval vs. oldval but i just felt better with the tag assignment.
>>>
>>>
>>>>I agree Alan. But I didn't want precision I just wanted it quick as all the controls, txt, cbo will be doing it. For me it doesn't matter that the value is back to what it is. Just tell the user you messed a value(s).
>>>>
>>>>The 2 keys that the user will be using to navigate is Enter and Tab, Shift+Tab, Ctrl+Tab. If he just uses these and doesn't effect the value it's okay.
>>>>
>>>>>Thanks Renoir, I haven't checked up yet but is CompObj() a VFP function?. If so this becomes very easy to compare two similar objects like you mentioned. My requirement was a bit different. I wanted to change a corner of the form to a different color as soon as a user modifies the vaule. If he changes back to the original value the save is not required but otherwise it is. Justto show he modified data I wanted to change the color and so I wanted something not very perfect but blazingly fast. I think interactivechange will the be the best way. I hope it does not fire if the user just presses enter to leave the field untouched. Keep you posted.
>>>>>
>>>>>That's the real key. InteractiveChange() will fire as soon as the user hits a key (the enter key alone won't fire the event). If the user changes back to the original as you note above, none of the methods mentioned (InteractiveChange, ProgrammaticChange, GetFldState) will help you. They will all imply that the value has changed. Renoir's method is much better. You can use GetFldState to narrow down the fields you need to check, but I doubt it will save you very much. Also, though, keep in mind that with GetFldState(), you can check the first bit to see if the record has been deleted by passing -1 instead of a field number. I'm not sure that Scatter Name with CompObj will give you that information.
>>>>>
>>>>>Alan
>>>>>
>>>>>
>>>>>>>Bhavbhuti,
>>>>>>>
>>>>>>>Alan makes an excellent point. I'm currently working in an application that constantly is asking, "Do you want to save this record?" when all the user did was go in, click on something then try to leave. In the past I have put a record into an object using Scatter Name when entering a form and then compared it to another object of the same record using CompObj when leaving the form (thanks to Cetin for that tip a couple years ago). I will eventually start to change the current application to do that as well.
>>>>>>>
>>>>>>>Renoir
>>>>>>>
>>>>>>>
>>>>>>>>>Just keep in mind though, that GetFldState(), InteractiveChange(), and ProgrammaticChange(), tell you that the field has been messed with. They don't really tell you if the value is different than it was coming in.
>>>>>>>>
>>>>>>>>Yes I have put it in the LostFocus() and I just wanted to know if the user modified once just to set a portion of the screen in a diff. color to get the users attention that save will be required.
>>>>>>>>
>>>>>>>>>
>>>>>>>>>If you truly want to know if the value is changed, you need to do your own comparisons.
>>>>>>>>>
>>>>>>>>>Alan
>>>>>>>>>
>>>>>>>>>>Thanks a lot David.
>>>>>>>>>>
>>>>>>>>>>>GetFldState()
>>>>>>>>>>>
>>>>>>>>>>>>I wanted a quick & efficient way to find out if say for eg. the text in a textbox / cbo or the status of a checkbox has changed.
>>>>>>>>>>>>
>>>>>>>>>>>>The controlsource for all these controls will be a view.
>>>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform