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.
Unfortunately, activation email could not send to your email. Please try again.

Changing height of custom ListBox in ComboBoxBarItem Pt 2

Thread ID:

Created:

Updated:

Platform:

Replies:

6122 Jul 31,2003 05:07 PM Aug 5,2003 10:54 AM Windows Forms 3
loading
Tags: Tools
Sue Harris
Asked On July 31, 2003 05:07 PM

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? Thanks, Sue

Ramesh Praveen [Syncfusion]
Replied On 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)? -Praveen

Sue Harris
Replied On August 3, 2003 01:04 PM

Exactly, (its a kind of tree - it can collapse or expand) Thanks, Sue

Ramesh Praveen [Syncfusion]
Replied On August 5, 2003 10:54 AM

Hi, 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; } else { for(int i = 0; i < this.fontcomboBoxBarItem1.MaxDropDownItems; i++) { listHeight += this.fontListBox1.GetItemHeight(i); } } this.fontListBox1.Height = listHeight; } else { if(this.fontListBox1.Items.Count > 0) this.fontListBox1.Height = this.fontListBox1.PreferredHeight; else 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; } Regards, Praveen

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;