Reputation: 85
In my project, I have a combobox and has 60 values in it. When I start running the application, I open the combobox to choose a value, it covers all my form application because it has lots of values in it. It does not look good visually. When I open the combobox to select a value, I want to display only 5 of them and user can select the other 55 item by scrolling down. How can I do this in C#?
Upvotes: 2
Views: 3978
Reputation: 13033
You should set the MaxDropDownItems
property of combobox
to 5 and IntegralHeight = true
When IntegralHeight property is set to true, the control automatically resizes to ensure that an item is not partially displayed. If you want to maintain the original size of the ComboBox based on the space requirements of your form, set this property to false. If the ComboBox does not contain any items, this property has no effect.
EDIT: another possibility is to set the dropdownheight directly
comboBox1.DropDownHeight = comboBox1.Font.Height * 5;
Upvotes: 4