Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I know which record in a grid has focus?
Message
 
À
02/02/2001 18:02:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00472020
Message ID:
00472054
Vues:
38
I understand what you are running into now. To prevent code from running more than desired in AfterRowColChange, I store the PK value of the record in a property and compare it to the current record. If it is different, I perform the action. If not, I don't. I think this might help your situation as well. The code in the AfterRowColChange looks something like.

If Thisform.PKFieldValue <> GridCursor.PKField
Thisform.PKFieldValue = GridCursor.PKField
* Code to perform action here
Endif

It's a tedious method, but it's simple and it works for me. Hope this helps.

>Hi Joel,
>
>Thanks. I'm playing around with Afterrowcolchange. I think it may have potential. The problem is still after my form runs, focus is returned to the textbox, which I assume re-fires the when of the textbox, which seems to cause afterrowcolchange to fire again, which gives me the endless loop again. I'll keep tyring various combinations, though, and see if I can get it to work.
>
>>>I have a client doing data entry in a grid with complex business rules. Heeding the advice of many developers far more knowledgable than I (and the extensive difficulty of similar past implementations), I am moving the actual data entry to a form, from which I can easily handle the conditional processing and interface.
>>>
>>>I want to simulate the a grid-looking entry, so I've created a long narrow form with no header and the same number of fields and text boxes as the grid. The issue I'm now facing is how do I know which record of the grid the user clicked in, so I can pass that paramter to the form. I'm using a view to populate the grid. The user can click on any line in the grid, and I want to pop open my little form with that same data.
>>>
>>>I can get the form to pop open precisely over the row in which the user clicked, which is pretty cool. But I can't get the right record number from my view. I've tried opening the entry form from the WHEN of one of the grid's textboxes, but when I try to find which record I'm in, it always gives me either the first record (if the grid didn't previously have focus) or the record I last was in. I tried the GOTFOCUS event of the text box, but that created all sorts of crazy behavior with the form - the textbox would get focus, then open my modal form, then get focus again, etc. etc. leading to an infinite loop.
>>>
>>>I have a few more things I'm going to try, but I was wondering if anyone had any thoughts or similar experiences, or perhaps an entirely different approach.
>>>
>>>Thanks in advance,
>>>
>>>David
>>
>>If you have the grid cursor in the data environment of the entry form, that could cause problems with the record pointer. If the problem is related to the event you are choosing, you might try the AfterRowColChange event of the grid.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform