We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Changing height of custom ListBox in ComboBoxBarItem

Hi, Could you please tell me how to change the initial height of a ComboBoxBarItem's custom ListBox? It always seems to create with the same height (of approximately 80 pixels). I would like to size my custom ListBox to fit the items. Thanks, Sue

6 Replies

RP Ramesh Praveen Syncfusion Team July 18, 2003 02:51 PM UTC

The ComboBoxBarItem has a MaxDropDownItems property that will let you change the height. Regards, Praveen


SH Sue Harris July 20, 2003 06:48 PM UTC

The MaxDropDownItems seems to have no effect when using a customer listbox, only when using the internal listbox. Do you have any other suggestions?


RP Ramesh Praveen Syncfusion Team July 22, 2003 06:16 PM UTC

I tested this in our XPMenus sample and this does seem to work in the fontComboBoxBarItem (in the TextEditorForms.cs). Regards, Praveen


SH Sue Harris July 27, 2003 09:49 PM UTC

It mostly works in the sample you suggested, but if the MaxDropDownItems is less than 4, it doesn't appear to work correctly. I have attached a sample which I'm experiencing the problem in. It has three combo box bar items, the first only has 3 items (and a MaxDropDownItems of 6), and I want to be able to set the height to only display the 3 items (exclude the white space below). Nothing I've tried will remove the white space. The second has several items, and the MaxDropDownItems of 3, and it is drawing 5.5 items. The last combo box bar item appears to work correctly. Regards, Sue


RP Ramesh Praveen Syncfusion Team July 29, 2003 12:49 AM UTC

Hi, It seems that there is a 75 pixel minimum height requirement for the dropdown hard coded in source. I have discussed with our developers and we will remove this in our next release. I will notify you. Sorry for the inconvenience. Regards, Praveen


SH Sue Harris August 1, 2003 12:54 AM UTC

Thanks, Although I'm still going to be waiting for that fix, I have found a workaround for anyone else experiencing the same problem. In the ListBox's OnVisibleChanged event: private void listBox1_VisibleChanged(object sender, EventArgs e) { if ( this.Visible ) { int newHeight = this.listBox1.ItemHeight * Math.Min(this.comboBoxBarItem1.MaxDropDownItems, this.listBox1.Items.Count); if ( ( this.listBox1.Parent != null ) && (this.listBox1.Parent.Parent != null) ) { this.listBox1.Parent.Parent.Height = newHeight; this.listBox1.Parent.Height = newHeight; this.listBox1.Height = newHeight; } } }

Loader.
Live Chat Icon For mobile
Up arrow icon