Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing controls with setfocus()
Message
From
23/08/2008 23:14:35
 
 
To
23/08/2008 20:57:07
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01341355
Message ID:
01341356
Views:
18
>On my Form, I have several txtBox controls that each (on lostfocus), update the RecordSource of a single grid on the form and refresh the grid, as the ordered row order has likely changed with the txtBox change. This works fine. I have now written some code that positions the grid’s ActiveRow appropriately (mainly so the rows above ActiveRow don’t hide above the top visible row with the ActiveRow on the top row). This works fine too.
>
>The problem is that to read the grid’s activerow position (needed to reposition the grid row content), the grid must have focus (I do this successfully in the txtBox lostfocus just before calling the grid refresh); but following the grid.refresh, I want to put the focus either back on the calling control, keypress a TAB and have it move without triggering the lostfocus event (again), or alternately put the focus back on the next control (which I was thinking of tabbing to) directly after finishing the grid’s refresh.
>
>I started coding this, but it’s getting very very messy, and I suspect that there might be a different approach that is cleaner. Any thoughts?

One approach would be to create a method in the form that contains all the objects in question - textboxes, grid etc. e.g. MyForm.MyCustomMethod()

This method would then be called from each of your Textboxes as required.

One useful trick would be to pass a reference to the calling control to .MyCustomMethod. That way, the method knows where to return focus when it's done i.e.
* MyTextBox.SomeMethod()

=ThisForm.MyCustomMethod( param1, param2, ..., This )

* MyForm.MyCustomMethod

LPARAMETERS ;
  param1 ;
  , param2 ;
  , ... ;
  , loCallingObject

* Do some stuff ...
* Then ...
loCallingObject.SetFocus()
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform