如何消除变量"panel1,panel2,panel3 ..等".在德尔福? [英] How to eliminate variables "panel1, panel2, panel3 .. etc." in Delphi?

查看:185
本文介绍了如何消除变量"panel1,panel2,panel3 ..等".在德尔福?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种类型

type
 TMain = class(TForm)

 panel1: Tpanel;
 panel2: Tpanel;
 panel3: Tpanel;
 panel4: Tpanel;
 panel5: Tpanel;
 panel6: Tpanel;
 panel7: Tpanel;
 panel8: Tpanel;
 ......
 panel45: Tpanel;

 label1: TLabel;
 label2: TLabel;
 label3: TLabel;
 label4: TLabel;
 label5: TLabel;
 label6: TLabel;
 label7: TLabel;
 ...........
 label109: TLabel;

如何在Type内一行内调用此组件?

How can i call this components in one line... inside the Type?

谢谢...

更新日期......

UpDate....

从anwser获得的基础并接受它,当我拥有所有这些组件并执行诸如button1.click的操作时,它的工作原理非常好...

Base from the anwser i get and accepted it works great when i have all this components and make the actions like a button1.click from the main form...

但是我以前是根据单位来做动作的...所以

But i use to make the actions from units... so

当我单击按钮时,我会执行一个过程DoMaths(Sender:TObject);

When i click a button i great a procedure DoMaths(Sender: TObject);

procedure Tform1.DoMaths(Sender: TObject);
  begin
    if TButton1(Sender).hint := 'Make the standard Package' then
      do_Maths_standard_package;
  end;

do_Maths_standard_package位于ComplexMaths单元中.

the do_Maths_standard_package is in unit ComplexMaths.

do_Maths_standard_package表单程序是ComplexMaths程序,它调用Form1 ... Form1.label1等组件.

is the procedure do_Maths_standard_package form unit ComplexMaths it calls some components form Form1... like Form1.label1 etc...

因此,当我调用RegisterClass(TLabel)并从类型中删除Tlabel时,它给出了一个错误,即找不到Label1 ...

So when i call the RegisterClass(TLabel) and erase the Tlabel from the type it gives an error that it cant find the Label1...

请有人帮我,以便不要从头开始做孔程序...

Please can someone help me so not to do the hole program from the start...

再次感谢您...

推荐答案

您可以删除TPanel或TLabel的名称,然后该名称仅存在于控件列表中,而不存在于表单的类型声明中.您要么需要保留一个标签和一个面板,要么 添加:

You can delete the name of a TPanel or TLabel then it only exists in the Controls List not in the Type declaration of the form. You either need to leave one Label and one panel or add:

initialization
  RegisterClass(TPanel);
  RegisterClass(Tlabel);
end.

在表单末尾.

这使具有很多控件的表单更加整洁.

This makes forms with a lot of controls much neater.

这篇关于如何消除变量"panel1,panel2,panel3 ..等".在德尔福?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆