zoukankan      html  css  js  c++  java
  • 组件数组

    在Delphi中,早期的时候我们没办法建立 像这样的 array of TButton 的组件数组。我们的使用的方法或许是:

    利用 Form  的Components属性,这个属性就是Form中所有的组件的数组,通过它来索引组件,显然这是不方

    便的:

    var
      Index : Integer;
    begin
      For Index:=0 to ControlCount-1 do
      begin
        if Components[Index] is TLinkLabel then
        begin
          (Components[Index] As TLinkLabel).Caption:='hello';
        end
      end;
    end;

    显然这样还是有局限性的。

    在DelphiXE 中我们会发现 TComponentList 这样的数据结构,就是通过它我们便可建立一个组件链表,它的父类

    是TObjectList,这个也可以做组件链表。

    var
      ComList : TComponentList;
    begin
      ComList := TComponentList.Create;
      ComList.Add(lbl1);
      ComList.Add(lbl2);
      ComList.Add(lbl3);
      (ComList.Items[0] as TLabel).Caption := 'Hello';
    end;
  • 相关阅读:
    Graphic
    GUI编程实战
    Swing 混合布局
    运算符与数据库函数
    mysq基础操作
    mysql常见问题处理
    static 与final abstract关键字
    JAVA面试
    Swing
    AWT的应用
  • 原文地址:https://www.cnblogs.com/wangmingshuo/p/3354693.html
Copyright © 2011-2022 走看看