Autor Beitrag
Pdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7
BeitragVerfasst: Mo 29.08.05 11:26 
Hi @ all ich habe folgendes problem:

ich habe eine listbox mit den einträgen_:

blabla1
blabla2
blabla3
wolwol4

so, wenn man jetzt auf eineneintrag klickt, soll in einem label1.caption die zeichenfolge stehen

also ich klicke auf wolwol4 und label1.caption ändert sich auf wolwol4

hab schon alles versucht und die suche benutzt aber nix gefunden


thx

Pdd

_________________
Wenn alles steht und nix mehr looft, denn isses was von Meikrosooft
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mo 29.08.05 11:30 
Die Methode ins OnClick von ListBox1:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.ListBox1Click(Sender: TObject);
var
 Index: Integer;
 ListBox: TListBox;
begin
  ListBox := Sender as TListBox;
  Index := ListBox.ItemIndex;
  if Index >= 0 then
   Label1.Caption := ListBox.Items[Index];
end;
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: Mo 29.08.05 11:58 
user profile icondelfiphan hat folgendes geschrieben:
Die Methode ins OnClick von ListBox1:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.ListBox1Click(Sender: TObject);
var
 Index: Integer;
 ListBox: TListBox;
begin
  ListBox := Sender as TListBox;
  Index := ListBox.ItemIndex;
  if Index >= 0 then
   Label1.Caption := ListBox.Items[Index];
end;

:lol: Warum denn so kompliziert? Er hat doch nur eine ListBox...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ListBox1Click(Sender: TObject);
begin
  if ListBox1.ItemIndex >= 0 then
     Label1.Caption := ListBox1.Items[ListBox1.ItemIndex];
end;
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mo 29.08.05 13:48 
user profile iconjaenicke hat folgendes geschrieben:
:lol: Warum denn so kompliziert? Er hat doch nur eine ListBox...

Bei grossen Projekten ist man meistens froh, wenn man in seinen Prozeduren so wenig Annahmen wie möglich trifft. Ist einfach eine Gewohnheit. Zugegeben, für einen DF-Post war es unnötig und ich hät den Methodennamen entsprechend allgemein benennen müssen. ;)