Tuesday, June 24, 2008 3:08 PM
kkchan
Add DataEnvironment class to form
DataEnvironment class has been introduced since VFP8. We could get more info from VFP help.
mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20FoxPro%208\dv_foxhelp.chm::/html/ctlDataEnvironment_Object.htm
Last few days, we tried to migrate some of the form's DataEnvironment to class for customization purpose. we then dynamically assign DEClass and DEClassLibrary property at form to have dynamic DataEnvironment.
However, we just hit error complaint that object "DataEnvironment" is not found. After some troubleshooting, we found that our application framework (VPME8) requires to access DE property values of DataEnvironment during form initialization. No matter what, the framework require DE's name to be DataEnvironment. In fact, DE's naming convention is DE's name + nth.
We found two workarounds:
Using AddObject()
SET CLASSLIB TO <DELib> ADDITIVE
THISFORM.RemoveObject("DataEnvironment")
THISFORM.AddObject("DataEnvironment", "<DE>")
Using Property
THISFORM.RemoveObject("DataEnvironment")
loDE = NEWOBJECT("<DE>", "<DELib>")
THISFORM.AddProperty("DataEnvironment", loDE)