Autor Beitrag
K-J
Hält's aus hier
Beiträge: 13



BeitragVerfasst: So 22.06.08 03:52 
Hallo,

ich habe mir eine ComboBox erstellt. Nun möchte ich aber, dass der User nicht in die Box reinschreiben kann. Wenn ich den "Style" auf "csOwnerDrawFixed" setze, kommt es zwar zum gewünschten Ergebnis, jedoch lässt sich dann nichts mehr in die Spalte "Text" eintragen.
Wie kann man das Reinschreiben in die ComboBox unterbinden und der Box dennoch eine Beschriftung geben?


Gruß
K-J


Moderiert von user profile iconChristian S.: Topic aus Sonstiges (Delphi) verschoben am So 22.06.2008 um 19:59
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 22.06.08 13:22 
//streich das... hatte die Frage nicht verstanden :roll:

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: So 22.06.08 18:57 
Hallo,

der folgende Workaround hat etwa die gleiche Auswirkung wie das setzen der Eigenschaft Text:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboBox1.Items.Add('Eintrag auswählen');
  ComboBox1.Items.Add('Eintrag2');
  ComboBox1.Items.Add('Eintrag3');
  ComboBox1.ItemIndex := 0;//angezeigt wird "Eintrag auswählen"
end;

procedure TForm1.ComboBox1DropDown(Sender: TObject);
begin
  ComboBox1.Items[0] := 'Eintrag1';
end;
sobald die Liste aufgeklappt ist, wird das erste Item ausgetauscht.
Du kannst dann aber nicht auf ItemIndex <> -1 prüfen und musst auf Items[ItemIndex] <> 'Eintrag auswählen'testen.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
K-J Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Mo 23.06.08 03:32 
Vielen Dank, Lannes.