因为需要,我有picturebutton ,pb_i (0<i<=10)
并且我已经将picturebutton全部放在groupbox中了~
我想使用循环来初始化他们的picturename
但是使用
pb_1.picturename="1.jpg"
pb_2.picturename="1.jpg"
.
.
.
pb_10.picturename"1.jpg"
这样的方式太恶心了
请问怎么样使用循环啊?
谢谢了啊~
------解决方案--------------------
...
- C/C++ code
PB控件的“宏替换” 问: 我想编写一个程序,代码如下: P_1.PictureName = 'help.gif' P_2.PictureName = 'help.gif' P_3.PictureName = 'help.gif' P_4.PictureName = 'help.gif' P_5.PictureName = 'help.gif' 请问有没有一种简单的办法,能让我用循环语句来实现? 如: for i = 1 to 5 P_***.PictureName = 'help.gif' next 答: 假设这段代码写在WINDOW的OPEN事件,THIS就是当前WINDOW: int i picture lp for i=1 to upperbound(this.Control) if typeof(this.Control[i])=picture! then lp=parent.Control[i] // 可以通过 lp.classname() 进一步确定是不是要修改的图像控件 lp.picturename='help.gif' end if next 你也可以定义一个 picture 变量数组来进行操作,通过OpenUserObject()使它们出现在window中。 如: int i picture p_temp for i = 1 to Upperbound(w_test.control) if left(w_test.control[i].classname,2) = 'p_' then p_temp = w_test.control[i] p_temp.picturename = '.......' end if next