![]() |
Text aus Listbox in Label
Hallo,
ich suche einen Befehl für folgendes: Ich habe eine Listbox mit vielen Items. Ich will jetzt eine beliebige Zeile (beispielsweise die 3. Zeile) in ein Label kopieren. Wie geht das? Könnte mir da jemand den Befehl für nennen? Vielen Dank schon einmla im Vorraus. mfg Superior |
Re: Text aus Listbox in Label
Hi,
Delphi-Quellcode:
*MFG*
procedure {OnClick der Listbox}
begin Label1.Caption := ListBox1.Items.Strings[ListBox1.ItemIndex] end; Manu :hi: |
Re: Text aus Listbox in Label
Hi,
da die Items der ListBox 0-basiert sind, heisst das, dass die 3. Zeile den Index = 2 hat, daher:
Delphi-Quellcode:
Ich hoffe das hilft Dir weiter :)
// aktuell ausgewählte zeile darstellen (<- ins OnClick der ListBox damit):
if ListBox1.ItemIndex > -1 then Label1.Caption := ListBox1.Items[ListBox1.ItemIndex]; // explizit das 3. item Label1.Caption := ListBox1.Items[2]; mfG mirage228 |
Re: Text aus Listbox in Label
Zitat:
Also vorher abfragen:
Delphi-Quellcode:
mfG
if ListBox1.ItemIndex > -1 then
Label1.Caption := ListBox1.Items[ListBox1.ItemIndex] mirage228 |
Re: Text aus Listbox in Label
Meine Güte,
er wird ja wohl selbst denken können oder :zwinker: |
Re: Text aus Listbox in Label
Ja super vielen Dank.
Es klappt. mfg Superior |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:26 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