![]() |
ComboBox1.Itemindex
hallo
habe auf form2 ein edit, in dieses edit gebe ich ein wort ein... alles wird in einer datei gespeichert mein problem ist eine combobox auf form1, die items werden mit
Delphi-Quellcode:
aus einer textdatei gefüllt.
with ComboBox1 do
begin Items.LoadFromFile(extractfilepath(application.exename)+ 'themen\themen.txt'); nun zu meiner frage: ich möchte, das in form2.edit eingegebene wort in der combobox auf form1 zu sehen ist. quasi als Form1.ComboBox1.Itemindex
Delphi-Quellcode:
procedure TForm2.Button1Click(Sender: TObject);
Var I : Integer; F : TextFile; temp:string; Begin memo1.lines.loadfromfile(extractfilepath(application.exename)+ 'themen\themen.txt'); memo1.lines.add(edit1.text); createDir(extractfilepath(application.exename)+ 'themen\'+''+edit1.Text+''); memo1.lines.savetofile(extractfilepath(application.exename)+ 'themen\themen.txt'); memo1.clear; close; Form1.ComboBox1.Items.LoadFromFile(extractfilepath(application.exename)+ 'themen\themen.thm'); Form1.ComboBox1.Itemindex:=edit1.Text; // <----das ist mein problem End; |
Re: ComboBox1.Itemindex
Zitat:
Delphi-Quellcode:
Gruß,
form1.combobox1.itemindex := form1.combobox1.items.indexof (edit1.text) ;
Tom |
Re: ComboBox1.Itemindex
Moin Horst,
meinst Du das:
Delphi-Quellcode:
?
// Zeile hinzufügen
Form1.ComboBox1.Items.Add(Form2.edit1.Text); // und diese dann im Editfeld der ComboBox anzeigen // (Items.Count-1) = Index des letzten Items Form1.ComboBox1.ItemIndex := Form1.ComboBox1.Items.Count-1; |
Re: ComboBox1.Itemindex
hallo christian
itemindex soll sein: das wort welches vorher in form2.edit1 eingegeben wurde. dein beispiel gibt ja den letzten eintrag zurück, wäre ja auch schon fast richtig nur habe ich die combobox auf sorted=true... dann haut das nicht mehr hin
Delphi-Quellcode:
wenn das nicht anders geht dann mache ich es so wie du es geschrieben hast...
Form1.ComboBox1.ItemIndex := Form1.ComboBox1.Items.Count-1;
merci ;) obwohl, wenn ich bedenke, die textdatei ist auch nicht sortiert. |
Re: ComboBox1.Itemindex
Delphi-Quellcode:
das funktioniert supi ;)
form1.combobox1.itemindex := form1.combobox1.items.indexof (edit1.text) ;
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:40 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