运行时动态添加和删除控件
1、使用控件数组。
dim i as int
load optch(1)
optch(1).visible=true
i=i+1
load optch(i)
with optch(i)
.caption"button" &i
.top=optch(i-1).top+300
.visible=true
end with
unload optch(i)
2、controls集合来添加控件
检查控件
dim on as contro
for each on in me.controls
on.enabled=true
next
private mop as optionbutton
private withevents mtxt as textbox '对事件进行响应
set mop=contros.add("vb.optionbutton","mopnew",fracolors)
mopnew.caption="new color"
set mtxt=controls.add("vb.textbox","mtxtname")
dim i as int
load optch(1)
optch(1).visible=true
i=i+1
load optch(i)
with optch(i)
.caption"button" &i
.top=optch(i-1).top+300
.visible=true
end with
unload optch(i)
2、controls集合来添加控件
检查控件
dim on as contro
for each on in me.controls
on.enabled=true
next
private mop as optionbutton
private withevents mtxt as textbox '对事件进行响应
set mop=contros.add("vb.optionbutton","mopnew",fracolors)
mopnew.caption="new color"
set mtxt=controls.add("vb.textbox","mtxtname")