Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Hi,
Pls see 'Q142885' in MSDN Knowledge Base.
How to Add the Data Environment to a Form Programmatically
...........................................................
oform1=CREATEOBJECT("Myform") && Instantiate the form
oform1.SHOW(0)
oform1.refresh
READ EVENTS
RETURN
DEFINE CLASS Data1 AS dataenvironment && DataEnvironment Class
Name = "Dataenvironment"
ADD OBJECT "Cursor1" AS MyCursor && ADD OBJECT for each
ENDDEFINE && cursor in dataenvironment
DEFINE CLASS MyCursor AS cursor && Cursor Class
Alias = "customer"
Database = "C:\vfp\samples\data\testdata.dbc"
CursorSource = "customer"
Name = "Cursor1"
ENDDEFINE
DEFINE CLASS Myform AS form
Top = 0
Left = 0
Height = 386
Width = 587
DoCreate = .T.
Caption = "Form1"
Name = "FORM1"
DataEnvironment="" && DataEnvironment is a property
&& of the form.
PROCEDURE Destroy
WAIT WINDOW PROGRAM() TIMEOUT 2
THISFORM.DATAENVIRONMENT.CLOSETABLES && Close tables at the end
ENDPROC && of destroy procedure.
PROCEDURE Unload
CLEAR EVENTS
ENDPROC
PROCEDURE Load
* The DataEnvironment is instantiated and the form property
* DataEnvironment references the object. The DataEnvironment
* is never actually added to the form. THISFORM.DATAENVIRONMENT
* is just a pointer to the DataEnvironment object.
THISFORM.DATAENVIRONMENT=CREATEOBJECT("Data1")
* Open the tables at the beginning of the LOAD.
THISFORM.DATAENVIRONMENT.OPENTABLES
WAIT WINDOW PROGRAM() TIMEOUT 2
ENDPROC
ENDDEFINE
.....................................................................
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