C# .NET - Why can i not set MaxDropDownItems property combobox?(Solved)

Asked By Gokhan Metepe on 27-Dec-11 08:10 AM
Earn up to 10 extra points for answering this tough question.

(Solved) I set IntegralHeight value to false and now it works.

I set it frop properties toolbar to "8" but still shows 30 items. Even i set it with code at form load, still i see 30 items. After 30 items scroll bar can be shown? Why?

Devil Scorpio replied to Gokhan Metepe on 28-Dec-11 02:39 PM
Hi,

You need to set the http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.integralheight.aspx to false when you setup your control (it defaults to true). From MSDN:

When this 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.

Add this line before you add the combobox to the Controls collection:

cb.IntegralHeight = false;

Reference - http://stackoverflow.com/questions/3868907/combobox-maxdopdownitems-is-not-working-when-adding-items-using-the-click-event