Einzelnen Beitrag anzeigen

Benutzerbild von Sunlight7
Sunlight7

Registriert seit: 17. Sep 2006
Ort: Sonnensystem, Zentral
1.522 Beiträge
 
Delphi 5 Standard
 
#7

Re: button, label... : variable

  Alt 19. Mai 2007, 01:03
Moin dino!

Meinst Du vielleicht so etwas?
Delphi-Quellcode:
   var Varibale:TComponent;
...
procedure TForm1.SetCaption;
begin
   If (Varibale is TButton) then
      TButton(Varibale).Caption:='Ich bin ein Button';

   If (Varibale is TLabel) then
      TLabel(Varibale).Caption:='Ich bin ein Label';

   If (Varibale is TCheckBox) then
      TCheckBox(Varibale).Caption:='Ich bin eine CheckBox';

   If (Varibale is TRadioButton) then
      TRadioButton(Varibale).Caption:='Ich bin ein RadioButton';
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   Randomize;
   Case Random(4) of
      0: Varibale:=Button1;
      1: Varibale:=Label1;
      2: Varibale:=CheckBox1;
      3: Varibale:=RadioButton1;
   end;

   SetCaption;
end;
Windows: Ja - Microsoft: Nein -> www.ReactOS.org
  Mit Zitat antworten Zitat