DELPHI中怎么在程序中遍历上面的全部控件
来源:互联网 发布:videoscribe 软件 编辑:程序博客网 时间:2024/04/27 14:39
对delphi了解不多,用到这个功能,SO。。。
1.
for i:=0 to Form1.ComponentCount-1 do
begin
Form1.Components[i]......
end;
2.
procedure TForm1.Button2Click(Sender: TObject);
var
i:Integer;
begin
for i:=1 ComponentCount-1 do
begin
Memo1.Lines.Add(Components[i].Name);
end;
end;
3.
procedure TestAdd(Component:TComponent);
var
i:integer;
begin
for i:=0 to Component.ComponentCount-1 do
begin
if Components[i].ComponentCount> 0 then
TestAdd(Components[i].);
Memo1.Lines.Add(Components[i].Name);
end;
end;
TestAdd(Self);
4.
procedure setread(zt: integer; sender: Tpanel);
var
i:integer;
begin
for i:=0 to sender.ControlCount -1 do
begin
if (sender.Controls[i] is Tedit) then
begin
if zt=1 then
(sender.Controls[i] as tedit).readonly:=true
else
(sender.Controls[i] as tedit).readonly:=false;
end;
end;
end;
5.
for m := o to Self.ComponentCount - 1 do
if Self.Componets[m] is TLabel then
6.
procedure TForm1.Button2Click(Sender: TObject);
var
i:Integer;
begin
for i:=0 to Self.ComponentCount-1 do
ListBox1.Items.Add(Self.Components[i].Name);
end;
以上来自网页资料:http://topic.csdn.net/t/20021125/16/1203961.html
:http://topic.csdn.net/t/20021125/16/1203877.html
最终我所用的方法:
procedure setDeactivate();
procedure TFrmPower1.setDeactivate();
var
i:integer;
begin
for i:=0 to self.ControlCount-1 do
begin
if(self.Controls[i] is TiLedRectangle) then
(self.Controls[i] as TiLedRectangle).OPCItemDeactivate(0);
if(self.Controls[i] is TiOdometer) then
(self.Controls[i] as TiOdometer).OPCItemDeactivate(0);
end;
end;
总结词:解决问题的思路很重要,一同事说C#里面有这种方法,所以我才会想起来去问度娘和古哥。。。。。。
- DELPHI中怎么在程序中遍历上面的全部控件
- 在delphi中ocx控件的安装
- 在DELPHI程序中注册OLE/COM控件
- 在DELPHI中HOOK程序的编写
- 在delphi中指针是怎么用的
- 在delphi中怎么表示和使用静态的变量?
- C#winfrom 中 TreeView 控件中带checkbox,怎么实现在父节点上打勾,选中全部子节点?
- delphi程序中动态生成控件的方法
- wpf在窗口的控件拖动、点击窗口中控件显示在最上面以及控件拖动不超过窗口边界
- 在Delphi中编写控件的基本方法
- 在Delphi中编写控件的基本方法(1)
- 在Delphi感知控件中显示"(VARBYTES)"的解决办法
- mfc在主框架CmainFrame中相应对话框上面控件的事件
- 在delphi中动态创建控件
- 在Delphi中使用IP控件
- 在Delphi中使用IP控件
- Delphi在Listview中加入Edit控件
- Delphi在Listview中加入Eeit控件
- 一位资深程序员的忠告(按:用体会更得体、牢骚更恰当!)
- double screenWidth = (double)HtmlPage.Window.Eval("screen.Width");
- 腾讯SOSO面试总结-细节决定成败
- ORACLE多表查询优化
- UBUNTU桌面没图标
- DELPHI中怎么在程序中遍历上面的全部控件
- MSSQLSERVER 批量 修改 字段 大写
- 修改centos打开文件最大限制
- ASP.NET将Session保存到数据库中
- 从 2.4 到 2.6:Linux 内核可装载模块机制的改变对设备驱动的影响—linux2.4单独编译驱动模块
- asp.net基础代码
- JAVA连接Oracle数据库实代码+详细注释
- 字典树(Trie树)的C程序实现代码
- 第十三章 3.计时器