So, I've rewritten your mouseUp a little:
private void lblSelect_MouseUp(object sender, MouseEventArgs e)
{
if (IsDropdownHit(e) && cmsItems.Tag == null)
{
cmsItems.Width = lblSelect.Width;
cmsItems.Show(lblSelect, 0, lblSelect.Height);
cmsItems.Tag = "Shown";
}
else
{
cmsItems.Hide();
cmsItems.Tag = null;
}
}
Now, it'll close. BUT - if you dont use the button to close, you will have to click twice to open it, next time.
Workaround for this "bug":
void cmsItems_Closed(object sender, ToolStripDropDownClosedEventArgs e)
{
Point c = PointToClient(Cursor.Position);
if (!IsDropdownHit(new MouseEventArgs(MouseButtons.Left, 1, c.X - lblSelect.Location.X, c.Y - lblSelect.Location.Y, 0)))
cmsItems.Tag = null;
}
Depending on how you designed your form, you might have to adjust the MouseEventArgs-Coordinates, to successfully determine Dropdownhits. I just added the CMenu Control to an empty form.
For the workaround, don't forget to add the handler into the constructor of your CMenu.cs:
cmsItems.Closed += cmsItems_Closed;