Autor Beitrag
CodexX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Do 20.04.06 18:45 
Wenn die Inhalte der Combobox länger sind als die Comboboy breit, dann werden die Einträge optisch abgeschnitten, sodass der Benutzer nicht alles lesen kann.
Ich kann mich jedoch an Programme erinnern, wo der aufgeklappte Teil der Combobox breiter war als das Element an sich, um alle Einträge im aufgeklappten Zustand vollständig anzeigen zu können.

Lässt sich das irgendwie einstellen? Oder gibt es eine andere Lösung dafür? (natürlich außer die eigentliche Combobox breiter zu machen ;))
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 22.04.06 17:18 
Du kannst die Breite des augeklappten Teils ändern:

www.dsdt.info/tipps/?id=451

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Sa 22.04.06 20:35 
Sehr gut, danke!

Darauf aufbauend, habe ich das wie folgt gelöst.
Die Breite wird an den breitesten Eintrag angepasst, aber nur dann, wenn dieser breiter ist als die Combobox an sich.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.Combobox1DropDown(Sender: TObject);
var TextWidth : Integer;
    i: Integer;
begin
  TextWidth := 0;

  for i := 0 to Combobox1.Items.Count - 1 do
  begin
    if TextWidth < Canvas.TextWidth(Combobox1.Items[i]) then
      TextWidth := Canvas.TextWidth(Combobox1.Items[i])
  end;

  if Combobox1.Items.Count > Combobox1.DropDownCount then
    TextWidth := TextWidth+17;

  if TextWidth < Combobox1.Width-5 then
    TextWidth := Combobox1.Width-5;

  Combobox1.Perform(CB_SETDROPPEDWIDTH, TextWidth+5, 0);


Zuletzt bearbeitet von CodexX am Sa 22.04.06 21:30, insgesamt 3-mal bearbeitet
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 22.04.06 20:47 
Müsste da nicht noch eine Überprüfung bzgl. der Scrollbarbreite rein?

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Sa 22.04.06 21:00 
Stimmt wohl. Habs oben editiert. (Wobei das für meine Zwecke keine Rolle spielt, da die Anzahl sowieso begrenzt ist.)