程序代码如下:
form1=CREATEOBJECT("myform")&&实例化表单
form1.show()
READ EVENTS
DEFINE CLASS myform as Form
Top=0
Left=0
Height=600
Width=1024
DoCreate = .T.
AutoCenter = .T.
Picture =''
BorderStyle = 0
Caption = "加油站安全评价变量编辑"
MaxButton = .F.
MinButton = .F.
Icon =''
WindowType = 1
BackColor =RGB( 255,255,255)
Name="form1"
DataEnvironment="" &&dataenvironment 是表单的一个属性
ADD OBJECT "grid1" as mygrid &&在表单中添加表格对象
PROCEDURE load
thisform.dataenvironment=CREATEOBJECT("data1")&&实例化Dataenvironment
thisform.dataenvironment.opentables &&打开表
ENDPROC
PROCEDURE destroy
thisform.dataenvironment.closetables &&关闭表
ENDPROC
PROCEDURE load
thisform.dataenvironment=CREATEOBJECT("data1")&&实例化Dataenvironment
thisform.dataenvironment.opentables &&打开表
ENDPROC
ENDDEFINE
DEFINE CLASS data1 as DataEnvironment &&数据环境类
name="dataenvironment"
ADD OBJECT "cursor1" as mycursor &&为数据环境中添加临时表
ENDDEFINE
DEFINE CLASS mycursor as Cursor &&添加Cursor类对象
alias= "doc_name"
cursorsource='doc_name.dbf' &&指向的表
name="cursor1"
ENDDEFINE
DEFINE CLASS mygrid as Grid
top=5
left=5
height=376
width=985
recordsourcetype=1
recordsource="doc_name"
ColumnCount = 6 &&增加此命令后会失去表格头名
ReadOnly=.T.
name="grid1"
ENDDEFINE