I am having a winform that contains a button which has a context menu strip dropping down when mouse hovers on it.
The condition checking whether the mouse is on the context menu strip is not working in the button's mouse leave event.
private void button1_MouseHover(object sender, EventArgs e)
{
contextMenuStrip1.Show(button1, new Point(0, button1.Height));
}
private void button1_MouseLeave(object sender, EventArgs e)
{
if (contextMenuStrip1.ClientRectangle.Contains(PointToClient(Cursor.Position)))
{
return;
}
else
{
contextMenuStrip1.Hide();
}
}