Entwickler-Ecke

Sonstiges (Delphi) - Listbox--->Bild


JannyR - Fr 19.01.07 19:41
Titel: Listbox--->Bild
Hi,

ich möchte nen kleines Prog machen wo eine Listbox ist und wenn man einen Eintrag davon auswählt ein Bild links daneben erscheint.

Da ich aber keine Ahnung habe wollte ich wissen ob ihr mir helfen könnt.

Danke


rn22 - Di 23.01.07 09:47

Also ich würd das so machen:


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.ListBox1Click(Sender: TObject);
var s: string;
    a: byte;
Begin
     a:=0;
     while (a<ListBox1.Items.Count)             //hier sucht er, welches Item du
       and (ListBox1.Text<>ListBox.Items[a])    //ausgewählt hast
        do Inc(a);     

     case a of
       0: s:='Bild1.bmp';
       1: s:='Bild2.bmp';
       2: s:='Bild3.bmp';
         //usw.
     end;

     Image1.Picture.LoadFromFile(s);  // Image1 sei jetzt mal dein Bild, 
                                      // in dem sich was tun soll
end;



ist es das, was du dir vorgestellt hattest?

Grüße
Mischa