private void viewMenuItem_DropDown_Closing(object sender, ToolStripDropDownClosingEventArgs e) { if (e.CloseReason != ToolStripDropDownCloseReason.ItemClicked) { return; } ToolStripDropDownMenu menu = sender as ToolStripDropDownMenu; ToolStripItem viewItem = menu != null?menu.GetItemAt(menu.PointToClient(Cursor.Position)) : null; if (viewItem == null) { return; } IMenuModelItem modelItem = this.GetModelItem(viewItem); if (modelItem == null) { return; } if (modelItem.Checkable) { e.Cancel = true; } }
private FindControlResult FindControl(ToolStripDropDownMenu ddm, int x, int y) { var p = ddm.PointToClient(new Point(x, y)); var item = GetAllChildren(ddm).FirstOrDefault(c => c.Bounds.Contains(p)); if (item == null) { var res = new FindControlResult(new Rectangle(), null); return(res); } else { var res = new FindControlResult(ddm.RectangleToScreen(item.Bounds), item.Name); return(res); } }