Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Prism PictureBox dynamisch erzeugen (.net) (https://www.delphipraxis.net/113486-picturebox-dynamisch-erzeugen-net.html)

smt 8. Mai 2008 14:55


PictureBox dynamisch erzeugen (.net)
 
Hallo,

ich hätte da ein Problem.. ;-)

Wieso zeigt diese Routine nichts an?



Delphi-Quellcode:
     with System.Windows.Forms.PictureBox.create do begin
         Parent := Panel1;
         Location.X:=10;
         Location.Y:=10;
         Size.Width:=50;
         Size.Height:=100;;
         Image.FromFile('2h.png');
         Visible:=True;
         show;
      end;
Ich versuche damit eine Picturebox dynamisch in ein Panel zu erzeugen. Und ich glaube auch, daß die Picturebox da ist, aber sie zeigt das Bild nicht an.
Hat jemand eine Lösung?

Vielen Dank

- Sascha -

Die Muhkuh 8. Mai 2008 15:43

Re: PictureBox dynamisch erzeugen (.net)
 
Vielleicht wäre ein absoluter Pfad zum Bild nicht schlecht?

mkinzler 8. Mai 2008 15:51

Re: PictureBox dynamisch erzeugen (.net)
 
Am Besten realtiv zum Exepfad oder in "Special Folder" ( Benurtzerverzeichnis, ...)

Khabarakh 8. Mai 2008 17:57

Re: PictureBox dynamisch erzeugen (.net)
 
Delphi-Quellcode:
Image := Image.FromFile('2h.png');
Jetzt weißt du, warum with böse ist, besonders in Verbindung mit Intellisense ;) .

[add] Soll natürlich nicht heißen, dass du die anderen Vorschläge ignorieren sollst. [/add]

smt 9. Mai 2008 10:25

Re: PictureBox dynamisch erzeugen (.net)
 
Ja, with ist wirklich böse.. Und das war natürlich auch des Rätels Lösung.

Das mit dem Pfad stimmt natürlich auch - war aber nicht das Problem. Hier hätte Delphi ja auch ne Exception ausgegeben, wenn die Datei nicht gefunden wird.
Auf jeden Fall mal vielen Dank an alle - bin jetzt schon mal viel weiter.. ;-)

VG Sascha


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:07 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz