FlexChart | ComponentOne
C1.Win.Ribbon.4.5.2 Assembly / C1.Win.Ribbon Namespace / RibbonItemCollectionBase Class / BeginUpdate Method
Example

In This Topic
    BeginUpdate Method (RibbonItemCollectionBase)
    In This Topic
    Maintains performance while items are being added or removed from the collection.
    Syntax
    'Declaration
     
    Public Sub BeginUpdate() 
    public void BeginUpdate()
    Remarks

    When adding a large number of items to the collection, you should use the BeginUpdate method to prevent the collection from updating its internal state each time an item is added to the list. Once you have completed the task of adding items to the list, call the EndUpdate method to resume regular processing.

    This way of adding items dramatically improves performance and is recommended when adding more than 10 or 20 items to the list.

    Example

    The code belows populates a RibbonComboBox with items containing the names of all the fonts installed in the system.

    You can run the sample as-is, then comment out the calls to BeginUpdate and EndUpdate to see the difference in performance.

    // get collection to populate
    RibbonItemCollection items = fontNameComboBox.Items;
                
    // call BeginUpdate to suspend regular processing
    items.BeginUpdate();
                
    // populate the list
    InstalledFontCollection ifc = new InstalledFontCollection();
    foreach (FontFamily ff in ifc.Families)
    {
        items.Add(new RibbonButton(ff.Name));
    }
                
    // resume regular processing
    items.EndUpdate();
    See Also