I have a program which can change the items in the ListBox in the OnSelect event. I swallow the MouseUp event so that the ComboBoxBarItem doesn't close the drop down ListBox, however this is leading to problem with the size of the listbox. In the case where the number of items reduces, I have white space under the last item. And in the case of additional items, the listbox doesn't expand to the MaxDropDownItems (if the listbox had been shorted due to insufficient number), it merely adds a scrollbar.
Is there any way for me to change the size of the listbox from the ListBox class? Also, the listBox parent is the Syncfusion.Windows.Forms.Tools.XPMenus.ListBoxContainer class, is there anyway I can get the ComboBoxBarItem?
RPRamesh Praveen Syncfusion Team August 1, 2003 01:47 PM
So, you will basically be adding/removing items when the drop-down is showing and you want to then update the height of the dropdown based on the current list items count and MaxDropDownItems settings (without closing the dropdown)?
SHSue HarrisAugust 3, 2003 01:04 PM
Exactly, (its a kind of tree - it can collapse or expand)
RPRamesh Praveen Syncfusion Team August 5, 2003 10:54 AM
Here is a method I added to our XPMenusMDI sample, in the TextEditorForm form to update the fontListBox1's height when it is dropped down (I modified the item count and called this method in the listbox's mousemove, the trigger of course will be something else in your case):
private void UpdateListDropDownHeight()
PopupControlContainer pcc = this.fontListBox1.Parent as PopupControlContainer;
// 1. Compute a listbox height based on the no. of items in the listbox.
if(this.fontcomboBoxBarItem1.MaxDropDownItems <= this.fontListBox1.Items.Count)
int listHeight = 0;
if(this.fontListBox1.DrawMode != DrawMode.OwnerDrawVariable)
listHeight = this.fontcomboBoxBarItem1.MaxDropDownItems * this.fontListBox1.ItemHeight;
for(int i = 0; i < this.fontcomboBoxBarItem1.MaxDropDownItems; i++)
listHeight += this.fontListBox1.GetItemHeight(i);
this.fontListBox1.Height = listHeight;
if(this.fontListBox1.Items.Count > 0)
this.fontListBox1.Height = this.fontListBox1.PreferredHeight;
this.fontListBox1.Height = this.fontcomboBoxBarItem1.MaxDropDownItems * this.fontListBox1.ItemHeight;
// 2. Update the parent PopupControlContainer's height.
pcc.Height = this.fontListBox1.Height + 2;
// 3. Also change the parent form's height
pcc.Parent.Height = pcc.Height;