// ********************************* // Message from Original Author: // // 2008 Jose Menendez Poo // Please give me credit if you use this code. It's all I ask. // Contact me for more info: menendezpoo@gmail.com // ********************************* // // Original project from http://ribbon.codeplex.com/ // Continue to support and maintain by http://officeribbon.codeplex.com/ using System.Collections.Generic; namespace System.Windows.Forms { /// /// Represents a collection of items that is hosted by the RibbonItemGroup /// public class RibbonItemGroupItemCollection : RibbonItemCollection { /// Group that this collection belongs to internal RibbonItemGroupItemCollection(RibbonItemGroup ownerGroup) { OwnerGroup = ownerGroup; } /// /// Gets the group that owns this item collection /// public RibbonItemGroup OwnerGroup { get; } /// /// Adds the specified item to the collection /// public override void Add(RibbonItem item) { item.MaxSizeMode = RibbonElementSizeMode.Compact; item.SetOwnerItem(OwnerGroup); base.Add(item); } /// /// Adds the specified range of items /// /// Items to add public override void AddRange(IEnumerable items) { foreach (RibbonItem item in items) { item.MaxSizeMode = RibbonElementSizeMode.Compact; item.SetOwnerItem(OwnerGroup); } base.AddRange(items); } /// /// Inserts the specified item at the desired index /// /// Desired index of the item /// Item to insert public override void Insert(int index, RibbonItem item) { item.MaxSizeMode = RibbonElementSizeMode.Compact; item.SetOwnerItem(OwnerGroup); base.Insert(index, item); } } }