The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
RPRamesh Praveen Syncfusion Team August 1, 2003 05:47 PM UTC
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
SHSue HarrisAugust 3, 2003 05:04 PM UTC
Exactly, (its a kind of tree - it can collapse or expand)
Thanks,
Sue
RPRamesh Praveen Syncfusion Team August 5, 2003 02:54 PM UTC
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