Information générale
Catégorie:
Gestionnaire d'écran & Écrans
>I have forms with tables in their Dataenvironment.
>At form design time, VFP stores relative path of those cursors into cursor CursorSource. property
>
>I need to change CursorSource property because at run-time, files are at different locations.
>The only reasonable place to do it seems to be BeforeOpentables event.
>However, it is not possible to loop through cursors: dataenvironment does not have objects collection and cursor object names are changed.
Here is a way to achieve kind of what you want in the form LOAD event.
If allows you to walk down the cursor tree using AMEMBERS.
You can then experiment with setting the various values of each
cursor property.
loData = THISFORM.DataEnvironment
lnCursorCount =AMEMBERS( laCursor , loData , 2 )
IF loData.AutoOpenTables = .T.
MESSAGEBOX("Please set form to AUTOOPENTABLES = .F." )
RETURN .F.
ENDIF
***************************************************************************
*&& If there are no cursors in the class dont go any further
***************************************************************************
IF lnCursorCount = 0
lvReturn = loData.OpenTables()
&& FIRE OPENTABLES EVENT TO SYNC DATAENVIRONMENT
RETURN .T.
ENDIF
FOR lnCount = 1 TO lnCursorCount
loCursor = GETPEM ( loData , laCursor(lnCount) )
lcBuffer = loCursor.database
&& YOU NOW HAVE A POINTER TO THE CURSOR AND CAN ALTER VARIOUS SETTINGS
loCursor = .NULL.
lcDatabase = ""
ENDFOR
&& FIRE OPEN TABLES MANUALLY
lvReturn = loData.OpenTables()
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement