I use a button to show context menu.
bool mnuOpen=false;
private void btnQLDT_Click(object sender, EventArgs e)
{
if (mnuOpen)
{
mnu.Hide();
mnuOpen = false;
}
else
{
mnu.Show(btnQLDT, new Point(0, btnQLDT.Height));
mnuOpen = true;
}
}
I want when click the button again, this menu will be hide. I try use a bool flag, but when click another space in form. It take 2 click to show menu again.
Problem at my second click not in button area, mnuOpen
dont set false
. How i can set false
when menu close? ContextMenu have Closed
Event, but I dont know how to use it. I try set mnuOpen =false
in this Event but fail :(
Please help me. Thank in advance!
Ok. I sloved this problem. Here: C# Winfoms Toolstripdropdown close on button click