Autor Beitrag
Grafix
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

Windows 7 Professional
Delphi 2009, PHP, Prolog, Python, Java
BeitragVerfasst: Sa 18.04.09 00:14 
Hey,

bei der TComboBox kann ich den ItemIndex (der Default auf -1 steht) nicht verändern. Ich kann zwar eine andere Zahl (0 in meinem Fall) reinschreiben, wenn ich bestätige springt er jedoch automatisch immer wieder auf -1. Hat das einen bestimmten Grund, wo liegt der Fehler?
Danke

Grafix
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: Sa 18.04.09 00:41 
Aber Items hast du definiert?
Grafix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

Windows 7 Professional
Delphi 2009, PHP, Prolog, Python, Java
BeitragVerfasst: Sa 18.04.09 15:02 
naja, ich definiere sie in TForm.create... daran könnte der Fehler liegen... danke für den Denkanstoß
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Sa 18.04.09 15:31 
Die Eigenschaft ItemIndex springt zurück, da sie die Obergrenze der Inhalte überschreitet. Du kannst sie erst setzen, nachdem du die ComboBox mit Daten gefüllt hast. Also greife im Source darauf zu :idea:
Grafix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

Windows 7 Professional
Delphi 2009, PHP, Prolog, Python, Java
BeitragVerfasst: So 19.04.09 14:44 
ah alles klar, und wie kann ich in dieser Box im Source beim Button klick (z.B.) auf eine bestimmte Position setzten?
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 19.04.09 15:44 
Du kannst ganz einfach, wie im Objekt-Inspektor auch, auf die Eigenschaft ItemIndex zugreifen - wo liegt das Problem?
Grafix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

Windows 7 Professional
Delphi 2009, PHP, Prolog, Python, Java
BeitragVerfasst: So 19.04.09 16:06 
naja, ich möchte dass den Itemindex den ich im code bestimmt habe auch im Form in der Combobox angezeigt wird, quasi "selected"
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 19.04.09 16:12 
Das macht er doch automatisch :gruebel:

Oder welche Delphi-Version hast du? Ich hab Turbo Delphi 2006, da geht das ohne Probleme.
Grafix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

Windows 7 Professional
Delphi 2009, PHP, Prolog, Python, Java
BeitragVerfasst: So 19.04.09 16:14 
ich habe Delphi 7, aber ich glaube ihr versteht mich nicht.
Wenn ich im Code per Button TComboBox.ItemIndex := 5 setzte, dann möchte ich dass im Form dies in der ComboBox auch angezeigt wird und das was an stelle des ItemIndex 5 steht im Form markiert wird.
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 19.04.09 16:19 
Und wenn Du den Style der ComboBox mal z.B. auf csDropDown stellst?
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 19.04.09 16:20 
Oder meinst du vllt.:

ausblenden Delphi-Quelltext
1:
2:
  ComboBox1.ItemIndex := 5;
  ComboBox1.SelectAll;

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
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: So 19.04.09 16:23 
So, hier mal ein Projekt, da siehst du, dass das Setzen des ItemIndexes eigentlich auch direkt angezeigt wird. :gruebel:
Einloggen, um Attachments anzusehen!
Grafix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

Windows 7 Professional
Delphi 2009, PHP, Prolog, Python, Java
BeitragVerfasst: So 19.04.09 16:42 
okay, jetzt hab ichs auch, danke für deine Mühe!!!