Autor Beitrag
MarioL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

Win XP, Win 7
Delphi 6
BeitragVerfasst: Sa 27.10.07 21:37 
Hallo, ich habe Image1 bis Image5, auf Tastendruck soll in einem der Images ein Bild geladen werden, wobei ein Integerwert festlegt welches Image es sein soll.

So ähnlich hatte ich es mir vorgestellt,
jedoch ist hierbei TImage und TString nicht Kompatibel

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
var ImageX : TImage;
      iX : Integer;
begin
  if Panel_ID.Tag < 5 then iX := Panel_ID.Tag else iX := 5;
    ImageX := 'Image' + IntToStr(iX);    //Nicht Kompatibel TImage und TString !!!
    ImageX.Picture.LoadFromFile(sFile);
end;


Wie kann ich ImageX eines der 5 TImages mittels Integerwert zuweisen?
Mario

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 27.10.07 21:45 
Ich sollte für diese Frage einen Entwurf erstellen, damit ich nicht jedesmal, wenn die Frage kommt, da noch viel schreiben muss... :roll: :mrgreen:

Ein Beispiel siehst du z.B. hier (vorletzter Post, z.B.):
www.delphi-forum.de/...c.php?t=72754#440450
ub60
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: Sa 27.10.07 21:46 
Such mal nach "FindComponent" in der Delphi-Hilfe, da wird Dir geholfen.

ub60
MarioL Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

Win XP, Win 7
Delphi 6
BeitragVerfasst: Sa 27.10.07 21:54 
vielen Dank,
hatte es schon mit ImageX := FindComponent('Image_P' + IntToStr(iCount)); versucht - ohne erfolg

mit
ausblenden Delphi-Quelltext
1:
TImage(FindComponent('Image_P' + IntToStr(iCount))).Picture.LoadFromFile(sPrVerz + sPrFile);					

funktioniert alles besten.

Mario

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt