在DELPHI中控件为动态加载的,所以不知道如何为控件数组指定处理事件,要求知道对哪个控件进行了操作~!谢谢大家~!急,在线等待~!

解决方案 »

  1.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      MyTimer1 := TNewTimer.Create(Self);
      MyTimer1.OnTimer :=  uTimer;
      MyTimer1.Interval := 1000;
      MyTimer1.Enabled := True;
    end;procedure TForm1.uTimer(Sender: TObject);
    begin
      Label1.Caption := IntToStr(StrToInt(Label1.Caption) + 1);
    end;
      

  2.   

    你可能没看明白我的意思
    我问的是例如生成了五个Edit,当在其中一个keypress时,显示出他的index,也就是哪个控件进行了keypress事件~!
      

  3.   

    首先定义好各种控件的事件函数 比如动态生成一个button,定义下面的函数,
    procedure Buttonclick(sender:TObject);var b1:TButton;b1:=TButton.create(self);
    b1.parent:=self;
    b1.onclick:=buttonclick;要知道对那个控件进行了操作,可以用 (sender as TControl).name 就可以判定。
      

  4.   

    能不能讲详细一些,是不是窗体上没有控件,在程序的运行中在加载控件
    比如说,按一个按扭就加一个DBGRID到窗体上?
    有问题请发信息到我的E-mail:[email protected]
      

  5.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Grids,  DB, DBTables, DBGrids, StdCtrls, Mask;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);    procedure MouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      Memo:Tmemo;
    begin
    try
      memo:=Tmemo.Create(self);
      memo.Top:=10;
      memo.Left:=10;
      memo.Parent:=form1;
      memo.OnMouseUp:= mouseup;
      memo.Show;
    except
      memo.Free;
    end;
    end;procedure TForm1.MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      showmessage('mouse up');
    end;end.
      

  6.   

    上面文章版权所有: 99guo(小兵)
      

  7.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, DB, DBTables;type
      TForm1 = class(TForm)
        DataSource1: TDataSource;
        Table1: TTable;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure btnclick(sender:Tobject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    var
      btn:array [1..10] of Tbutton;{$R *.dfm}
    procedure Tform1.btnclick(sender:Tobject);
    begin
      showmessage('you click');
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
       btn[1]:=Tbutton.Create(self);
       btn[1].Parent:=form1;
       btn[1].Top:=20;
       btn[1].Left:=20;
       btn[1].OnClick:=btnclick;
       btn[1].Show;
    end;end.
      

  8.   

    上面这是个例子,你把btn[1]改为你要的第i个空件btn[i]就行了
      

  9.   

    ComponentCount代表窗体上的控件数;
    Components[ComponentCount]代表的是什么控件;
    比如Components[1]是第一个控件是什么?
    知道这些应该可以解决你的问题!
    有问题请发信息到我的E-mail:[email protected]
      

  10.   

    对,按 99guo(小兵) 说的做应该可以,加一些判断语句就可以了吧!!!
    有问题请发信息到我的E-mail:[email protected]