您的位置:程序门 -> vb -> 基础类



自动改变窗体大小


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


自动改变窗体大小
发表于:2008-01-19 10:40:35 楼主
请问如何随着窗体加载控件的增加而自动改变窗体尺寸?
我现在的程序是
private   sub   command4_click()
load   text1(text1.count)   '装载一个新的控件
text1(text1.count   -   1).top   =   text1(text1.count   -   2).top   +   text1(text1.count   -   2).height   +   100   '设置新控件的位置
text1(text1.count   -   1).visible   =   true   '显示新控件最后,把这段代码放到合适的位置;当然,这里只是告诉你了一个最简单的添加方法,具体的还要根据你自己的实际要求来做相应处理,那也不过就是控件数量以及新控件的摆放位置了。希望对你有用   :)
text1(text1.count   -   1)   =   0   '新增文本框请0

load   text2(text2.count)   '装载一个新的控件
text2(text2.count   -   1).top   =   text2(text2.count   -   2).top   +   text2(text2.count   -   2).height   +   100   '设置新控件的位置
text2(text2.count   -   1).visible   =   true
text2(text2.count   -   1)   =   0   '新增文本框请0

load   command1(command1.count)   '装载一个新的控件
command1(command1.count   -   1).top   =   command1(command1.count   -   2).top   +   command1(command1.count   -   2).height   +   100   '设置新控件的位置
command1(command1.count   -   1).visible   =   true
command1(command1.count   -   1).caption   =   "计算"   &   format(command1.count,   "00")

if   text1(text1.count   -   1).top   >   form1.height   -   text1(text1.count   -   1).height   then
form1.height   =   form1.height   +   text1(text1.count   -   1)
end   if


end   sub


private   sub   command2_click()
if   text1.count   =   1   then   exit   sub
unload   text1(text1.count   -   1)
unload   text2(text2.count   -   1)
unload   command1(command1.count   -   1)   '装载一个新的控件

end   sub

但随着控件数量增加超出了窗体,我想加条语句自动改变窗体尺寸
发表于:2008-01-19 11:06:501楼 得分:0

在上面的程序中下面这段意思是随新控件超出窗体而改变窗体高度,可实现不了。
if       text1(text1.count       -       1).top       >       form1.height       -       text1(text1.count       -       1).height       then  
form1.height       =       form1.height       +       text1(text1.count       -       1)  
end       if  
发表于:2008-01-19 11:08:432楼 得分:0
不好意思,解决了
发表于:2008-01-19 12:12:373楼 得分:0
ding


快速检索

最新资讯
热门点击