zoukankan      html  css  js  c++  java
  • 控件对象引用

    The following example creates 20 edit boxes, using FindComponent with the edit box name to access each newly created edit box
    procedure TForm1.Button1Click(Sender: TObject);
     1 var
     2   i: Integer;
     3 const
     4   NamePrefix = 'MyEdit';
     5 begin
     6   for i := 1 to 20 do begin
     7     TEdit.Create(Self).Name := NamePrefix + IntToStr(i);
     8     with TEdit(FindComponent(NamePrefix + IntToStr(i))) do
     9     begin
    10       Left := 10;
    11       Top := i * 20;
    12       Parent := self;
    13     end;
    14   end;
    15 end;
    
    
    **********************************************************************

    动态创建控件(属性和Tag)并绑定事件test

     1 procedure TForm1.test(Sender: TObject);  
     2 var  
     3    l_busin_flag:Integer;  
     4 begin  
     5    l_busin_flag:=(Sender as TButton).Tag;  
     6    ShowMessage(IntToStr(l_busin_flag)+'Hello');  
     7 end;  
     8   
     9 procedure TForm1.FormCreate(Sender: TObject);  
    10 var  
    11   btns: TButton;  
    12   i:Integer;  
    13 begin  
    14   for i:=0  to  5 do  
    15   begin  
    16       btns:=TButton.Create(Self);  
    17       btns.Width:=100;  
    18       btns.Height:=20;  
    19       btns.Caption:=IntToStr(i)+'动态按钮';  
    20       btns.OnClick:=test;  
    21       btns.Left:=i*100;  
    22       btns.Tag:=i;  
    23       btns.Parent:=Self;  
    24   end;  
    25 end;  
  • 相关阅读:
    image对象
    Frame/IFrame 对象
    Form 对象
    JavaScript 对象 实例
    button对象
    正则介绍以及多种使用方法
    js /jquery停止事件冒泡和阻止浏览器默认事件
    一些兼容性的知识
    面试题总结
    事件
  • 原文地址:https://www.cnblogs.com/zhrong/p/5670774.html
Copyright © 2011-2022 走看看