Link to home
Start Free TrialLog in
Avatar of AndersWP
AndersWP

asked on

How do I set the height of a combobox?

How do I  set the height of an ownerdrawn combobox in Delphi? I have tried setting the Height property at design time and at various stages of initialization. I have also tried selecting a larger font for the combobox.
All without success.

Does anyone know how to get around this?

Thanks in Advance
AndersWP
Avatar of williams2
williams2

This is not that easy to get around with. You cannot set the Height property on ComboBoxes, but you can do this:

procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboBox1.Style:= csOwnerDrawFixed;
  // It's nessecary to set this property due to changes in size.
  ComboBox1.DropDownCount:= 12;
  ComboBox1.ItemHeight:= 15;
end;

To set specific height, you must individually change the properties untill they fit into your needs. Else you'll have to make up your own ComboBox component.
Avatar of AndersWP

ASKER

Thank you for your swift answer. Unfortunately is does not really cover my problem. Re-reading my question, I can see that I not been specific enough, so let me elaborate a bit:

What I have is a csOwnerDrawVariable combobox, and the height that troubles me is the height of the edit field part of the box, i.e. the height of the box when it is not dropped down.

Sorry about that.
ASKER CERTIFIED SOLUTION
Avatar of inter
inter
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you - I somehow got the idea that what you propose would only affect the height of items in the dropped down list, but it works just fine.