1

I have a TComboBox with csOwnerDrawFixed style.

I've set the DropDownCount to 20. When there are many items in the list, it is only showing 16.

When there are 2 items in the list, it only shows one, with a scrollbar to select the other.

When there is only one item in the list, the DropDown is completely empty!

How can I fix this?

I am asking the question and giving the answer. I spent hours looking for the solution and eventually found the answer after getting a clue from a post on some other web site. I thought I would put my answer here so that future visitors with the same problem can find the answer easily.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
David Dubois
  • 3,842
  • 3
  • 18
  • 36
  • This other post should have a pointer to this one, but I don't know how to do that. https://stackoverflow.com/questions/35122957/delphi-seattle-tcombobox-dropdowncount-not-working-when-using-ownerdraw-style – David Dubois Oct 09 '18 at 16:57

1 Answers1

3

In my case I had an OnMeasureItem event handler that returns Height := 19;

But my ItemHeight property was set to 16.

The DropDown would be made large enough to hold 20 items that are each 16-pixels tall, but since each item was 19, that only left room for 16 items to be shown.

I solved the problem by setting ItemHeight to 19, to match my OnMeasureItem event.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
David Dubois
  • 3,842
  • 3
  • 18
  • 36