Esempio n. 1
0
        public UndoButton()
        {
            // Initialize the custom control
            m_dropControl = new UndoDropDownControl()
                                {
                                    MinimumSize = new Size(SetWidth, SetHeight) // <- important
                                };
            m_dropControl.ItemChosen += m_dropControl_ItemChosen;

            // ...hosted by a ToolStripControlHost
            m_toolHost = new ToolStripControlHost(m_dropControl)
                         	{
                         		Size = new Size(SetWidth, SetHeight),
                         		Margin = new Padding(0)
                         	};

            // ... and shown in a ToolStripDropDown.
            m_toolDrop = new ToolStripDropDown()
                         	{
                         		Padding = new Padding(0)
                         	};
            m_toolDrop.Items.Add(m_toolHost);

            this.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.BackgroundImageLayout = ImageLayout.Stretch;

            // There is no OnDropDownOpening to override, so I guess we have to do it this way.
            this.DropDownOpening += UndoButton_DropDownOpening;
        }
Esempio n. 2
0
        public UndoButton()
        {
            // Initialize the custom control
            m_dropControl = new UndoDropDownControl()
            {
                MinimumSize = new Size(SetWidth, SetHeight)                                         // <- important
            };
            m_dropControl.ItemChosen += m_dropControl_ItemChosen;

            // ...hosted by a ToolStripControlHost
            m_toolHost = new ToolStripControlHost(m_dropControl)
            {
                Size   = new Size(SetWidth, SetHeight),
                Margin = new Padding(0)
            };

            // ... and shown in a ToolStripDropDown.
            m_toolDrop = new ToolStripDropDown()
            {
                Padding = new Padding(0)
            };
            m_toolDrop.Items.Add(m_toolHost);


            this.DisplayStyle          = ToolStripItemDisplayStyle.Image;
            this.BackgroundImageLayout = ImageLayout.Stretch;

            // There is no OnDropDownOpening to override, so I guess we have to do it this way.
            this.DropDownOpening += UndoButton_DropDownOpening;
        }