CLEAR ALL
CLOSE PROCEDURES
*SET PROCEDURE TO "MyForm", "MyLogin","otherForm" && 我没这个文件
PUBLIC addLineNum
addLineNum=2
runOtherForm1()
CLOSE PROCEDURES
&&CLOSE ALL
return
PROCEDURE runOtherForm1
PUBLIC
otherForm1
otherForm1=CREATEOBJECT("m1Form")
otherForm1.show
READ EVENTS
RETURN
ENDPROC
*DEFINE CLASS m1Form as myForm
DEFINE CLASS m1Form as Form
showWindow=2
caption="功能模块1窗口"
autoCenter=.t.
windowType=1
minLabelFontSize=8
&&定义最小标签的字号
minOtherFontSize=9
&&定义最小文本框、列表框、按钮字号
minTitleFontSize=18
&&定义标题标签小号字号
minDistance=2
&&定义控件间最小间距
minControlTop=24
&&定义最顶端控件的最小顶边
minControlLeft=12
&&定义最左端控件的最小侧边距
height=300 &&为了测试更多
&&ADD OBJECT howManyLine as spinner WITH spinnerHighValue=4,spinnerLowValue=1,value=1,left=180
ADD OBJECT addLine as commandButton WITH caption="增加行"&&,initValue=2
ADD OBJECT button1 as commandButton WITH caption="返回主程序",left=thisform.addLine.left+thisform.addLine.width+10
&&根据微调按钮,增加条目开始
ADD OBJECT clfl1 as clfl_C WITH top=135,left=12,height=24,width=48,value="材料分类1"
ADD OBJECT clmc1 as clmc_C WITH top=135,left=63,height=24,width=77,value="材料名称1"
PROCEDURE addLine.click
flName="clfl"+ALLTRIM(STR(addLineNum))
clName="clmc"+ALLTRIM(STR(addLineNum))
thisform.addobject('&flName','TextBox')
thisform.addobject('&clName','TextBox')
* thisform.addobject('&flName','clfl_C')
* thisform.addobject('&clName','clmc_C')
&&我没用你的类,用你的类,不会累加,只能显示1个,也就是直到 clmc2,clmc3以后就不动了,估计是top=135+30*addLineNum的addLineNum值问题,改为30*addLineNum,不是100*addLineNum
WITH thisform.&flName
.top=135+30*addLineNum
.left=12
.height=24
.width=48
.value="材料分类"+ALLTRIM(STR(addLineNum))
.visible=.t.
ENDWITH
WITH thisform.&clName
.top=135+30*addLineNum
.left=63
.height=24
.width=77
.value="材料新名称"+ALLTRIM(STR(addLineNum))
.visible=.t.
ENDWITH
addLineNum=addLineNum+1
&&thisform.height=thisform.&clName.top+200
thisform.refresh
ENDPROC
*!*
PROCEDURE howManyLine.valid
*!*
howLine=thisform.howManyLine.value
*!*
IF howLine>=2
*!*
FOR addLine=2 TO howLine
*!*
flName="clfl"+ALLTRIM(STR(addLine))
&&用宏代实现分类名称和材料名称,不知道怎么样?
*!*
clName="clmc"+ALLTRIM(STR(addLine))
&&或者用这个先确定名称
*!*
MESSAGEBOX(clName,64,"运行了吗?")
*!*
ADD OBJECT &flName as textBox WITH top=135+addLine,left=12,height=24,width=48,value="材料分类"+ALLTRIM(STR(addLine))
*!*
ADD OBJECT &clName as textBox WITH top=135+addLine,left=63,height=24,width=77,value="材料名称"+ALLTRIM(STR(addLine))
*!*
ENDFOR
*!*
*!*
ENDIF
*!*
thisform.refresh
*!*
ENDPROC
&&根据微调按钮,布局结束
PROCEDURE button1.click
RELEASE thisform
ENDPROC
PROCEDURE Destroy
MESSAGEBOX(thisform.clmc2.value,64,"控件增加了吗?")
MESSAGEBOX("模块1表单销毁了",64,"123")
CLEAR EVENTS
ENDPROC
ENDDEFINE
DEFINE CLASS clfl_C as TextBox
top=135+30*addLineNum
left=12
height=24
width=48
value="材料分类"+ALLTRIM(STR(addLineNum))
visible=.T.
ENDDEFINE
DEFINE CLASS clmc_C as TextBox
top=135+30*addLineNum
left=63
height=24
width=77
value="材料新名称"+ALLTRIM(STR(addLineNum))
visible=.T.
ENDDEFINE
[此贴子已经被作者于2015-12-21 16:27编辑过]