System.Windows.Forms.CommandBar.AddItems C# (CSharp) Method

AddItems() private method

private AddItems ( ) : void
return void
        private void AddItems()
        {
            NativeMethods.SendMessage(Handle, NativeMethods.TB_BUTTONSTRUCTSIZE, Marshal.SizeOf(typeof(NativeMethods.TBBUTTON)), 0);

            int extendedStyle = NativeMethods.TBSTYLE_EX_HIDECLIPPEDBUTTONS | NativeMethods.TBSTYLE_EX_DOUBLEBUFFER;
            if ((style == CommandBarStyle.ToolBar) || (this.Style == CommandBarStyle.TextToolBar))
            {
                extendedStyle |= NativeMethods.TBSTYLE_EX_DRAWDDARROWS;
            }

            NativeMethods.SendMessage(Handle, NativeMethods.TB_SETEXTENDEDSTYLE, 0, extendedStyle);

            this.UpdateImageList();

            for (int i = 0; i < items.Count; i++)
            {
                NativeMethods.TBBUTTON button = new NativeMethods.TBBUTTON();
                button.idCommand = i;
                NativeMethods.SendMessage(this.Handle, NativeMethods.TB_INSERTBUTTON, i, ref button);

                NativeMethods.TBBUTTONINFO buttonInfo = this.GetButtonInfo(i);
                NativeMethods.SendMessage(this.Handle, NativeMethods.TB_SETBUTTONINFO, i, ref buttonInfo);
            }

            // Add ComboBox controls.
            this.Controls.Clear();
            for (int i = 0; i < items.Count; i++)
            {
                CommandBarComboBox comboBox = this.items[i] as CommandBarComboBox;
                if (comboBox != null)
                {
                    NativeMethods.RECT rect = new NativeMethods.RECT();
                    NativeMethods.SendMessage(this.Handle, NativeMethods.TB_GETITEMRECT, i, ref rect);

                    rect.top = rect.top + (((rect.bottom - rect.top) - comboBox.Height) / 2);

                    comboBox.ComboBox.Location = new Point(rect.left, rect.top);
                    this.Controls.Add(comboBox.ComboBox);
                }
            }

            this.UpdateSize();
        }