private void OnItemClick(object sender, MouseEventArgs e) { // Set new selection index _imageSelect.SelectedIndex = _imageIndex; // Should we automatically try and close the context menu stack if (_imageSelect.AutoClose) { // Is the menu capable of being closed? if (_layout.CanCloseMenu) { // Ask the original context menu definition, if we can close CancelEventArgs cea = new CancelEventArgs(); _layout.Closing(cea); if (!cea.Cancel) { // Close the menu from display and pass in the item clicked as the reason _layout.Close(new CloseReasonEventArgs(ToolStripDropDownCloseReason.ItemClicked)); } } } _needPaint(this, new NeedLayoutEventArgs(true)); }