how can i stop the ToolStripMenuItem dropdown menu from removing itself upon selecting an item?

Viewed 190

A ToolStripMenuItem in my menuStrip contains all the columns of my table in it's DropDown that i can select to hide/unhide but i have to re-open the dropdown (click the item) every time i want to do this. Is there a setting that allows the this menu to persist after an item is selected from it?

I plan on the Dropdown to only close when the mouse hovers off of it ideally, or when another control in my window is selected (which i would assume is the Lose Focus event).

I implemented the first answer to this but it has a really noticeable flicker every time an item is selected: enter image description here

The first way i tried to fix it involved disabling item.DropDown.AutoClose but that introduces the question of what events trigger AutoClose so i can re-implement the events that i want. i tried MouseLeave and LoseFocus events but i can't seem to get them to work for this purpose in a reliable way. (read my responses to the first answer)

1 Answers

You can write a method that will reopen the menu strip item programmatically and call it from the button click event.
here is an example for such method:

private void OpenDropDown(int dropindex = 0)
{
    ToolStripDropDownItem item = menuStrip1.Items[dropindex] as ToolStripDropDownItem;

    if (item.HasDropDownItems)
    {
        // Re-openes the menustrip item
        item.ShowDropDown();
    }
}
Related