Board index » delphi » Autosize a TComboBox

Autosize a TComboBox

Hello,

The TEdit component has the autosize property which when set to false
stops the box from expanding as the font size is increased.  The
TCombobox, however does not allow for this.  DOes anyone know of a way
to stop a combobox from expanding with the font!?!

Thanks,

Darron

darron_sta...@aici.com

 

Re:Autosize a TComboBox


Quote
> The TEdit component has the autosize property which when set to false
> stops the box from expanding as the font size is increased.  The
> TCombobox, however does not allow for this.  DOes anyone know of a way
> to stop a combobox from expanding with the font!?!

Darron,

this seems to be something controlled by the windows combobox control
itself, not by the Delphi TComboBox wrapper class. I see no way to
override it, at least not easily. One could conceivably try to find the
window handles for the edit control and the drop-down buttons and change
their sizes directly via SetWindowPos.

Peter Below (TeamB)  100113.1...@compuserve.com)

Re:Autosize a TComboBox


The only way to control combobox height is to make it owner-draw.

1. Set Style to csOwnerDrawFixed or csOwnerDrawVariable.

2. Adjust ItemHeight to whatever you want.

3. There's a bug in TCombobox at design time so you won't see the control's
height change until you force it to be recreated. Just toggle the Ctl3D
property.

Delphi provides a default drawing implementation that looks something like
the standard combobox, so even though you've specified owner-draw, you
don't actually have to provide any painting code.

--
Tim Knipe | Plasmatech Software Design | http://plasmatech.com
Explorer controls for Delphi, C++Builder and soon ActiveX!

Quote
> Darron, wrote
> > The TEdit component has the autosize property which when set to false
> > stops the box from expanding as the font size is increased.  The
> > TCombobox, however does not allow for this.  DOes anyone know of a way
> > to stop a combobox from expanding with the font!?!

Other Threads