AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

ComboBox1.Itemindex

Ein Thema von horst · begonnen am 26. Okt 2003 · letzter Beitrag vom 26. Okt 2003
Antwort Antwort
horst

Registriert seit: 1. Jul 2003
347 Beiträge
 
Delphi 2007 Professional
 
#1

ComboBox1.Itemindex

  Alt 26. Okt 2003, 22:00
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:
with ComboBox1 do
begin
  Items.LoadFromFile(extractfilepath(application.exename)+ 'themen\themen.txt');
aus einer textdatei gefüllt.
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;
  Mit Zitat antworten Zitat
Benutzerbild von Jelly
Jelly

Registriert seit: 11. Apr 2003
Ort: Moestroff (Luxemburg)
3.741 Beiträge
 
Delphi 2007 Professional
 
#2

Re: ComboBox1.Itemindex

  Alt 26. Okt 2003, 22:06
Zitat von horst:
   Form1.ComboBox1.Itemindex:=edit1.Text; // <----das ist mein problem
Ersetze die Zeile durch
form1.combobox1.itemindex := form1.combobox1.items.indexof (edit1.text) ; Gruß,
Tom
  Mit Zitat antworten Zitat
Christian Seehase
(Co-Admin)

Registriert seit: 29. Mai 2002
Ort: Hamburg
11.105 Beiträge
 
Delphi 11 Alexandria
 
#3

Re: ComboBox1.Itemindex

  Alt 26. Okt 2003, 22:07
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;
?
Tschüss Chris
Die drei Feinde des Programmierers: Sonne, Frischluft und dieses unerträgliche Gebrüll der Vögel.
Der Klügere gibt solange nach bis er der Dumme ist
  Mit Zitat antworten Zitat
horst

Registriert seit: 1. Jul 2003
347 Beiträge
 
Delphi 2007 Professional
 
#4

Re: ComboBox1.Itemindex

  Alt 26. Okt 2003, 22:16
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
  Form1.ComboBox1.ItemIndex := Form1.ComboBox1.Items.Count-1; wenn das nicht anders geht dann mache ich es so wie du es geschrieben hast...
merci

obwohl, wenn ich bedenke, die textdatei ist auch nicht sortiert.
  Mit Zitat antworten Zitat
horst

Registriert seit: 1. Jul 2003
347 Beiträge
 
Delphi 2007 Professional
 
#5

Re: ComboBox1.Itemindex

  Alt 26. Okt 2003, 22:20
form1.combobox1.itemindex := form1.combobox1.items.indexof (edit1.text) ; das funktioniert supi
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:30 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