Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
570
Dropdown in UltraComboEditor takes too long to drop down the first time.
posted

Hi,

I am creating a value list of fonts and setting the appearance property of each font in the list. There are about 300 fonts in the list.
The value list is then assigned to the UltraComboEditor.ValueList.

This works except that the first time the drop down is selected, it takes about 8 second for the drop down to display.

I suspect that the appearance property is assigned to each of the ValueListItems when the drop down is selected.
Is there a way to increase the performance of the drop down?

Here is a sample of my code.

This code is executed in the dialog constructor that the UltraComboEditor resides in.

 ValueList fontNameList = new ValueList();

            foreach (string fontName in _annotationProperties.FontNames)
            {

                DefaultableBoolean bold = fontName.IndexOf("Bold") != -1 ? DefaultableBoolean.True : DefaultableBoolean.False;
                DefaultableBoolean italic = fontName.IndexOf("Italic") != -1 ? DefaultableBoolean.True : DefaultableBoolean.False;
                fontName.Trim();
                ValueListItem valueListItem = new ValueListItem() { DataValue = fontName, DisplayText = fontName };

                valueListItem.Appearance.FontData.Name = fontName;
                valueListItem.Appearance.FontData.Bold = bold;
                valueListItem.Appearance.FontData.Italic = italic;

                fontNameList.ValueListItems.Add(valueListItem);
            }

            _fontListDropDown.ValueList = fontNameList;
            _fontListDropDown.SortStyle = ValueListSortStyle.Ascending;
            _fontListDropDown.DropDown();

     ValueList fontNameList = new ValueList();

            foreach (string fontName in _annotationProperties.FontNames)
            {

                DefaultableBoolean bold = fontName.IndexOf("Bold") != -1 ? DefaultableBoolean.True : DefaultableBoolean.False;
                DefaultableBoolean italic = fontName.IndexOf("Italic") != -1 ? DefaultableBoolean.True : DefaultableBoolean.False;
                fontName.Trim();
                ValueListItem valueListItem = new ValueListItem() { DataValue = fontName, DisplayText = fontName };

                valueListItem.Appearance.FontData.Name = fontName;
                valueListItem.Appearance.FontData.Bold = bold;
                valueListItem.Appearance.FontData.Italic = italic;

                fontNameList.ValueListItems.Add(valueListItem);
            }

            _fontListDropDown.ValueList = fontNameList;
            _fontListDropDown.SortStyle = ValueListSortStyle.Ascending;
            _fontListDropDown.DropDown();

  • 1560
    Offline posted

    Hello,

    I have been looking into your question and found this forum thread where similar question has been discussed. As my colleague suggested  there, in case that you are experiencing performance issues with the UltraComboEditor, what can be done is to use the UltraCombo instead. It is optimized for using larger amounts of data since the UltraCombo will cache the data (as long as your DisplayMember field is IComparable) and then it will use binary searches. As the binary searches are faster than linear ones (which are used by the UltraComboEditor) the UltraCombo performs better than the UltraComboEditor with a lot of data. The slower performance on the initialization is because the combo builds its sorted list for the binary search. This is the tradeoff for the faster overall performance.

    Another thing you could do is to have the value in the edit portion exist in the items collection of the combo, as when dropping down the list the Combo is searching the list trying to find an item on the list that matches what's currently in the edit portion. If there is no matching item, then that means the combo has to search the entire list. Also the UltraCombo has a ScrollStyle property, which if you set to Deferred will help a lot with the performance while scrolling.

    Sincerely,
    Teodosia Hristodorova
    Associate Software Developer