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 19:44:04
 
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:
01654557
Vues:
66
>>>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.
>
>
>This code will fail IF you are in different work area NOT GridCursor.
>To be safe this should be:
>
>IF SEEK(lcId, 'LookupCursor')
>   REPLACE Field2 WITH LookupCursor.Field3 IN GridCursor
>ELSE
>   REPLACE Field2 WITH '' IN GridCursor
>ENDIF
>
My code would not fail because it IS IN the Valid() method of the grid column's textbox, since we are IN the grid, then, we are IN the grid's cursor area. Let's remember that whenever we are IN a grid the cursor bound to the grid is SELECTed.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform