运行时动态添加和删除控件

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")

posted on 2005-10-15 15:40  奇远  阅读(310)  评论(0编辑  收藏  举报

导航