Home > Back-end >  Set winform combobox list height
Set winform combobox list height

Time:10-01

I have a combobox which can have a different number of items at any given time. I have the list count set to 8 and it works fine. But if the list is actually less than 8 then it shows the extra blank lines. How can I shrink the height based on the number of items in the list if less than 8?

Thank you.

CodePudding user response:

You can iterate the combobox with foreach and remove when the value is null

CodePudding user response:

Eureka! Knew it was easy.

List<String> _reasons = new List<String>() {"a","b"};
if (_reasons.Count < Reason.Properties.DropDownRows)
    Reason.Properties.DropDownRows = _reasons.Count;
  • Related