Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Textbox in grid column.... When is cursor updated?
Message
De
25/09/2017 15:02:05
 
 
À
25/09/2017 14:11:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01654540
Message ID:
01654547
Vues:
60
>>Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
>>
>>Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
>>
>>As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
>>
>>
>>** UPDATE **
>>
>>I have confirmed that if I use the down arrow to exit the textbox and move to the next *row* in the grid, the calculations in AfterRowColChange() work perfectly, so that shows that the value from the textbox is applied to the cursor beforehand when changing rows. But, when moving horizontally from one column to another, I have to move *2* columns before the calculations based on the underlying cursor work properly.
>>
>>.
>
>I have a rule when working within grids: Never reference another grid column by object name, instead reference the cursor's column name (field name).
>
>Supposing I have a form with a grid with two columns, each column with its respective textbox, and the grid's RecordSource = 'GridCursor', I would write the following code in the Valid() method of the textbox of the first column:
>
>
>
>LOCAL lcId
>lcId= This.Value
>IF SEEK(lcId, 'LookupCursor')
>   REPLACE GridCursor.Field2 WITH LookupCursor.Field3
>ELSE
>   REPLACE GridCursor.Field2 WITH ''
>ENDIF
>
>
>I hope this helps you.

Why so much code ? Anything preventing
 REPLACE GridCursor.Field2 WITH IIF (SEEK(This.Value, 'LookupCursor'), LookupCursor.Field3, '')
to work, perhaps as a line triggered by focus change?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform