Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Spinner
Message
De
29/07/2006 16:49:05
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01141401
Message ID:
01141551
Vues:
17
>>>>
>>>>In some cases it might be. However if a routine update is needed to underlying source no need to mess with iac.
>>>>PS: I read about dodefault, it would do default anyway unless supressed by nodefault (IOW sometimes it means you're doıng the default twice).
>>>>Cetin
>>>
>>>So far, I have tracked the problem to the fact that in the InteractiveChange the value of the field bound to this control does not change. The value is being updated because when I save the record the value from spinner is updating the field. I tried putting DODEFAULT() and removing DODEFAULT() but to no avail.
>>
>>But I meant why you need code there.
>
>Cetin,
>
>Here is the reason I have code in InteractiveChange method of the spinner. Imagine three controls on a form: a Spinner to show Quantity, a Textbox to show Unit Price and a Textbox to show Extended Price. User enters Unit Price and then clicks in the Spinner control clicking mouse on Up or Down wheel. As he/she changes the quantity I want to show the Extended price, obviously as a product of unit price and quantity. So I put the following simple code in the InteractiveChange:
>
>
>replace EXT_PRICE with UNIT_PRICE * QUANTITY in V_MYVIEW
>
>
>The above didn't work so I changed the code to use the Value of the Spinner and it work now.
>
>
>replace EXT_PRICE with UNIT_PRICE * this.value in V_MYVIEW
>
>
>I wish I can understand why using the field value of the field bound to the Spinner didn't work.

I don't use spinners very often, and when I do use them I find I run into odd things like you're experiencing.

I'm in the midst of rebuilding my workstation so I don't have VFP9 installed yet to test. But here's one theory:

- A spinner is designed to be clicked on many times. In fact, IIRC if you click and hold an up or down arrow on a spinner it "accelerates".

- If you bind a column to the spinner, and it works as you seem to expect (i.e. updating the underlying column on each .InteractiveChange), then you could be forcing tens of updates per second during accelerated spinning. Also, any code you have in .InteractiveChange will also be called tens of times per second. This could cause a lot of network/DB traffic. Also, if you're using a framework that tracks whether a field's value has changed as a result of user input, any such code will also be heavily exercised.

- Instead, what you *probably* want is to hook code into the MouseUp event of the up or down arrow (or of the whole spinner itself, if either of these events exist) so as soon as you release the mouse button, the related fields get updated once, not during all the intermediate values you don't care about.

- Bearing all the above in mind, it may actually be by design that the controlsource isn't updated for each .InteractiveChange.

Other things to think about:

- As a test, you might try binding to a table column rather than a view column, to see if it's anything to do with your view

- If you're using a framework, test with raw VFP to see if that makes a difference. Alternately, use the Debugger and/or SET COVERAGE to see what's actually going on.

- You could consider using a simple unbound spinner, and handling your updates manually e.g. only when the record is finally saved. This may be a more efficient design
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform