Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding DataEnvironment to a form programmatically
Message
 
To
13/02/2002 22:46:21
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00619865
Message ID:
00619872
Views:
9
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
Map
View

Click here to load this message in the networking platform