新闻  |   论坛  |   博客  |   在线研讨会
[分享]delphi实现控件数组
jobs | 2012-10-06 21:50:32    阅读:2717   发布文章

  我们在使用Delphi时有时会发现一个问题,就是Delphi没有像VB或者VF等软件一样可以很方便的定义控件 数组。在编写一个多媒休演示光盘的时候因要用到很多Image控件,而且如果没有用控件数组的话将使程序写起来非常麻烦而且复杂化。所以想了很久,最 终决定用定义数组变量的方式来实现控件数组。

Delphi也可以实现控件数组,用定义数组变量实现控件数组

  下面是代码:

procedure Tfrm_main.FormCreate(Sender: TObject);
var
  image:array[1..12] of TImage; //用于存放12个image图像框
  label:array[1..12] of TLabel;//用于存放12个label标签
begin
//将image对象付给image数组
   image[1]:=image1;
   image[2]:=image2;
   image[3]:=image3;
   image[4]:=image4;
   image[5]:=image5;
   image[6]:=image6;
   image[7]:=image7;
   image[8]:=image8;
   image[9]:=image9;
   image[10]:=image10;
   image[11]:=image11;
   image[12]:=image12;
  //将label对象付给label数组
   label[1]:=label1;
   label[2]:=label2;
   label[3]:=label3;
   label[4]:=label4;
   label[5]:=label5;
   label[6]:=label6;
   label[7]:=label7;
   label[8]:=label8;
   label[9]:=label9;
   label[10]:=label10;
   label[11]:=label11;
   label[12]:=label12;
end;

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
推荐文章
最近访客