首页 > 编程 > Delphi > 正文

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

2019-11-18 18:29:54
字体:
来源:转载
供稿:网友
 

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

  小弟表达能力有限,此文章又是本人第一次发表文档,所以不周到之处请各位仁兄多多包涵。

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

  下面是代码:

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;


上一篇:Delphi+Word解决方案参考

下一篇:《参透delphi》书评

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
学习交流
热门图片

新闻热点

疑难解答

图片精选

网友关注