Recent

Author Topic: Checking content of a dynamically created editbox?  (Read 237 times)

perhen

  • New Member
  • *
  • Posts: 15
Checking content of a dynamically created editbox?
« on: March 31, 2020, 01:27:49 pm »
Hello

I have created a TEdit instance dynamically and want to check the content when exiting. The procedure to use is the same as for a static TEdit instance. I hope anyone can give me some help. See code below:


TForm1 = class(TForm)
    Edit1: TEdit;
    procedure Edit1Exit(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
    eBox : TEdit;
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  eBox := TEdit.Create(Form1);
  eBox.Top := 100;
  eBox.left := 100;
  eBox.Parent := Form1;
  eBox.OnExit:= Edit1Exit(nil);  //  ???????
end;

procedure TForm1.Edit1Exit(Sender: TObject);
begin
  // Check content
end;

end.

ASerge

  • Hero Member
  • *****
  • Posts: 1634
Re: Checking content of a dynamically created editbox?
« Reply #1 on: March 31, 2020, 01:37:56 pm »
1. Enclose the source code in "code" tags. There is a corresponding button in the built-in message editor.
2. Correction
Code: Pascal  [Select][+][-]
  1. eBox.OnExit := @Edit1Exit;
3. Better to define eBox as local if it is not used outside the procedure, or in the private section if it is used inside the unit.

perhen

  • New Member
  • *
  • Posts: 15
Re: Checking content of a dynamically created editbox?
« Reply #2 on: March 31, 2020, 03:14:14 pm »
Thank you ASerge! :D Just what I was looking for.

I will remember the code button next time. Sory. :(

 

TinyPortal © 2005-2018