Componentes - criando em runtime

Top  Previous  Next

Var

  MyButton  :  TButton;

 

MyButton := TButton.Create(MyForm);    //  MyForm now "owns" MyButton

with MyButton do

  BEGIN

    Parent := MyForm;    //  here MyForm is also the parent of MyButton

    height := 32;

    width := 128;

    caption := 'Here I Am!';

    left := (MyForm.ClientWidth - width) div 2;

    top := (MyForm.ClientHeight - height) div 2;

  END;

 

 

Eventos

=======

 

memo.onchange:=memo1Change;

 

procedure TForm1.Memo1Change(Sender: TObject);

begin

   panel1.caption:='Content has been changed';

end;