Sabtu, 26 Desember 2015

Membuat Komponen (OOP)




interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
var a:TEdit ;  b:TComboBox ;
begin
a:= TEdit.Create(nil) ;
a.Parent := form2 ;
a.Left := Button1.Left + Button1.Width + 20 ;
a.Text := 'Komponen edit' ;
a.Top := Button1.Top ;
a.Height :=   Button1.Height ;

b:= TComboBox.Create(nil) ;
b.Parent := form2 ;
b.Left := a.Left ;
b.Items.Add('Indra') ;
b.Items.Add('Rani') ;
b.Items.Add('Dwi') ;
b.Items.Add('Putra') ;
b.Top := a.Top + a.Height + 20  ;

end;

end.

Tidak ada komentar:

Posting Komentar