Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi ComboBox - Einträge per Button auswählen (https://www.delphipraxis.net/22040-combobox-eintraege-per-button-auswaehlen.html)

eljot 11. Mai 2004 17:42


ComboBox - Einträge per Button auswählen
 
Habe eine ComboBox mit einigen Einträgen.
Möchte einen davon auswählen, wenn ich einen Button klicke.
Habe es mit ComboBox.TextSel versucht, weil ich dachte man könnte hiermit arbeiten.

ComboBox1.TextSel :='xyz';

Er scheint dann den Richtigen Wert in der ComboBox anzuspringen.
Der ItemIndex ist nicht auf den entsprechenden Wert gesetzt. Er ist dann -1;
Obwohl sich der Eintrag xyz an vierter oder fünfter stelle befindet.

Hat jemand eine Idee ?!

Niko 11. Mai 2004 17:46

Re: ComboBox - Einträge per Button auswählen
 
Wie wär's mit
Delphi-Quellcode:
ComboBox1.ItemIndex := 5;

mirage228 11. Mai 2004 17:47

Re: ComboBox - Einträge per Button auswählen
 
Du kannst ja machen:
Delphi-Quellcode:
var
  Index: Integer;
begin
  Index := ComboBox1.Items.IndexOf('xyz');
  if Index > -1 then
  ComboBox1.ItemIndex := Index;
end;
mfG
mirage228


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:33 Uhr.

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