General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
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
.....................................................................
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only