Share via


DataEnvironment Object

Created when you create a form, form set, or report. A DataEnvironment object functions as a container for the Cursor, CursorAdapter, and Relation objects associated with the form, form set, or report.

Note

You can set only the following DataEnvironment properties at run time: DataSource, DataSourceType, InitialSelectedAlias, Name, OpenViews, and Tag. For a new property setting to take effect, you must call the CloseTables and OpenTables methods for the DataEnvironment object. Setting any other DataEnvironment properties at run time generates an error.

DataEnvironment

Remarks

You can define and subclass the DataEnvironment class. From a form, you can save the existing data environment as a visual class library (.vcx) file by selecting the form, choosing Save As Class from the File menu, and selecting DataEnvironment. All DataEnvironment properties, methods, and events are available as appropriate in the Properties window after you open the Class Designer. However, you can access the Data Environment Designer only from the Form Designer, not from the Class Designer.

At design time, you can add a preexisting DataEnvironment class to a form from a class library toolbar or in code using the AddObject method. However, Visual FoxPro considers the DataEnvironment class added in either manner as a member class, not a native data environment.

You can use the Form DEClass and DEClassLibrary properties to specify and load an external DataEnvironment class at design time or run time. Visual FoxPro supports the DEClass and DEClassLibrary properties for form (.scx), visual class library (.vcx), and program (.prg) files but not for form sets or in the Report Designer.

For more information, see the DEClass Property and DEClassLibrary Property properties. For more information about the data environment for forms and form sets, see Creating Forms.

See Also

Reference

DataEnvironment Object Properties, Methods, and Events

Form Object

AddObject Method

Cursor Object

CursorAdapter Class

Other Resources

Objects, Collections, and Classes

Objects, Collections, and Classes

Language Reference (Visual FoxPro)