Autor Beitrag
crandzy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN 2000
D2006 Prof
BeitragVerfasst: Mi 20.04.05 07:47 
Hi Leute,

ich habe 10 Buttons von 0 - 9. Diese Buttons sollen wenn Sie gedrückt werden eine Zahl in ein Edit-Feld schreiben. Gibt es eine möglichkeit das ganze zu verkürzen, damit man nicht 10 mal schreiben muss:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button9Click(Sender: TObject);
begin
  Edit1.Text:=Edit1.Text+'9';
  Edit1.SetFocus;
end;


Hat da jemand einen Vorschlag

Danke

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mi 20.04.05 08:31 
Hallo

du könntest die Tag-Eigenschaft nutzen. Stell z.B. im OI bei jedem Button die Zahl 0-9 als Tag ein. Als clickereignis schreibst du dann 1x:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ButtonClick(Sender: TObject);  
begin  
  Edit1.Text:=Edit1.Text+inttostr(TComponent(Sender).Tag);  
  Edit1.SetFocus;  
end;

und weißt allen anderen Buttons diese Ereignisroutine zu.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
crandzy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN 2000
D2006 Prof
BeitragVerfasst: Mi 20.04.05 08:49 
Danke so hats funktioniert :D
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 20.04.05 08:52 
Und ohne den Tag-Umweg:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ButtonClick(Sender: TObject);  
begin  
  Edit1.Text:=Edit1.Text+Copy(TButton(Sender).Name),length(TButton(Sender).Name), 1);
  Edit1.SetFocus;  
end;

!Ungetesteter Source!
crandzy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN 2000
D2006 Prof
BeitragVerfasst: Mi 20.04.05 09:35 
wäre auch eine gute Idee hat auch funktioniert mit einer kleinen Änderung

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button7Click(Sender: TObject);
begin
 Edit1.Text:=Edit1.Text+Copy((TButton(Sender).Caption),1, 1);
 Edit1.SetFocus;
end;


Ich bräuchte .caption da meinen Button-Namen abweichen von der Funktion sprich Button13 soll z.b. die 9 ins EditFeld schreiben

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt.

_________________
In Wirklichkeit ist die Realität ganz anders