我在窗口中动态建立了一个编辑框的数组.但是要怎么在这些编辑框中禁止输入英文字符.也就是说只能输入数字.

解决方案 »

  1.   

    在Edit的OnKeyPress中写:
    if not ( Key in ['0'..'9'] ) then
       Key = #0;
      

  2.   

    同意楼上的!但加上‘.’键和‘back space’键可能更好。
    if not ( Key in ['0'..'9','.',#8] ) then
       Key := #0;
      

  3.   

    在Edit的OnKeyDown中写:
    如:EditArray[0].OnClick = EditOnKeyDown();然后再自定义事件EditOnKeyDown就OK了
      

  4.   

    你们这群笨蛋,我都说了是动态产生的.你叫我去哪找ONKEYPRESS.啊!
      

  5.   

    edit1.OnKeyPress := MyEditKeyPress;啊!
      

  6.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TEdt =class(TEdit)
        procedure KeyDown1(Sender: TObject; var Key: Char);
    end;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    var
      Form1: TForm1;
      edt1 :tedt;
    implementation{$R *.dfm}procedure TEdt.KeyDown1(Sender: TObject; var Key: Char);
    begin
      if not ( Key in ['0'..'9','.',#8] ) then
       Key := #0;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      edt1:=tedt.Create(self);
      edt1.Parent :=form1;
      edt1.OnKeyPress  :=edt1.KeyDown1;
    end;
    end.应该没问题了吧!!!!