System.Windows.Forms.CommandBarItemCollection.Add C# (CSharp) Method

Add() public method

public Add ( CommandBarItem item ) : void
item CommandBarItem
return void
        public void Add(CommandBarItem item)
        {
            this.items.Add(item);

            if (this.commandBar != null)
            {
                this.commandBar.AddItem(item);
            }
        }

Usage Example

        public void Show(Control control, Point point)
        {
            CommandBarItemCollection chevronItems = new CommandBarItemCollection();
            Size size = ClientSize;

            for (int i = 0; i < items.Count; i++)
            {
                NativeMethods.RECT rect = new NativeMethods.RECT();
                NativeMethods.SendMessage(Handle, NativeMethods.TB_GETITEMRECT, i, ref rect);
                if (rect.right > size.Width)
                {
                    CommandBarItem item = items[i];
                    if (item.Visible)
                    {
                        if ((!(item is CommandBarSeparator)) || (chevronItems.Count != 0))
                        {
                            chevronItems.Add(item);
                        }
                    }
                }
            }

            this.contextMenu.Mnemonics = false;
            this.contextMenu.Items.Clear();
            this.contextMenu.Items.AddRange(chevronItems);
            this.contextMenu.Show(control, point);
        }
All Usage Examples Of System.Windows.Forms.CommandBarItemCollection::Add