您的位置:程序门 -> vb -> 控件



如何将button控件数组按数量动态排列成几行?


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


如何将button控件数组按数量动态排列成几行?
发表于:2007-04-17 19:44:25 楼主
如何将button控件数组按数量动态排列成几行?详细些,谢谢
发表于:2007-04-17 20:12:121楼 得分:0
在窗体上先建一个command1,index设为0,窗体scalemode设定为pixel

再放一个command2,代码如下:

private   sub   command2_click()
dim   i   as   integer  
dim   tolnum   as   integer       '按钮总数
dim   n   as   integer                 '每行按钮数量

n   =   4         '假设每行按钮数为4
for   i   =   1   to   tolnum
    load   command1(i)
    command1(i).visible   =   true
    command1(i).move   100   +   (i   mod   n)   *   100,   100   +   int(i   /   n)   *   50     '间距和行距自己设定
next   i

end   sub
发表于:2007-04-17 20:15:292楼 得分:0
初始画面上只有command(0)

option   explicit
dim   i   as   integer

private   sub   command2_click()
for   i   =0   to   n
    load   command1(i)   '增加控件
    j=i   mod   5
    k=fix   (i/5)
    command1(i).visible   =   true
    command1(i).left   =   (j   -   1)   *   1000
    command1(i).top   =   k*500
next  
end   sub
没调试看行吗?
发表于:2007-04-17 21:28:383楼 得分:0
option   explicit
dim   i   as   integer

private   sub   command2_click()
for   i   =0   to   n
    load   command1(i)   '增加控件
    j=i   mod   5
    k=fix   (i/5)
 
    command1(i).left   =   (j   -   1)   *   1000
    command1(i).top   =   k*500
  command1(i).visible   =   true
next  
end   sub


快速检索

最新资讯
热门点击