How can Combobox with csOwnerDrawFixed Style behave like csDropDown?

I use the TComboBox component with the style property set to csOwnerDrawFixed, I implement OnDrawItem and everything works fine, now I want the combobox to behave as if the csDropDown style (with the csOwnerDrawFixed style behaves like the csDropDownList style), I have in mind with an internal editor. Is it possible?

+7
source share
2 answers

The Delphi TComboBox wrapper does not support an editable owner style, but the main Windows control does this and is easy to enable.

Create a new child class as follows:

TComboBox = class(StdCtrls.TComboBox) public procedure CreateParams(var Params: TCreateParams); override; end; procedure TComboBox.CreateParams(var Params: TCreateParams); begin inherited; if Assigned(OnDrawItem) then Params.Style := Params.Style or CBS_OWNERDRAWFIXED end; 

Set Style to csDropDown and assign OnDrawItem , as you already did.

+7
source

None of the OwnerDraw styles support the presence of an edit field in TComboBox . Instead, you have to use a separate TEdit .

0
source

All Articles