"Pin" controls items in the ToolstripMenu

First, a little overview of what my current user interface looks like:

Current UI

Note that, among other things, everything else in the ToolStripControlHost is standard WinForms.

In short, I want to have something akin to a ToolStripControlHost, but I need it to "pin" to the bottom of the menu, basically so that when there are many items, it doesn't scroll like the rest of the menu items.

After some searching I came to the conclusion that maybe the painting setting might be the solution, I don't know if it really is.

Here's some sample code, but I'm not sure how useful it is:

public ToolStripDropDownButtonContainer(ToolStripDropDownButton button)
{
    this.UIControl = button.GetCurrentParent();
    this.Button = button;

    if (this.Button.Tag == null)
    {
        this.Button.Tag = true;

        this.Button.DropDownDirection = ToolStripDropDownDirection.AboveLeft;
        ToolStripDropDownMenu menu = (ToolStripDropDownMenu)this.Button.DropDown;

        menu.SuspendLayout();
        try
        {
            menu.BackColor = Color.White;
            menu.ShowImageMargin = false;
            menu.ShowCheckMargin = false;
            menu.AutoSize = true;
            menu.Margin = Padding.Empty;
            menu.Padding = Padding.Empty;
            menu.GripMargin = Padding.Empty;
            menu.GripStyle = ToolStripGripStyle.Hidden;
            menu.MinimumSize = new Size(310, 0);
            menu.MaximumSize = menu.MinimumSize;
            // TODO pin panel (or some control) to the bottom-side of the menu
        }
        finally
        {
            menu.ResumeLayout();
        }
    }
}

      

+3


source to share


1 answer


My solution to this problem is to completely avoid the normal menu control system and instead display a menu FlowLayoutPanel

that contains my menu items instead.

This is due to the need to add a few tricks to get the panel to behave well with the user interface. An additional advantage of this approach is greater flexibility and control over the system.



On the other hand, I noticed performance degradation when I have a ton of sub-items, but I'll investigate this separately.

+3


source







All Articles