private void tabControl1_MouseClick(object sender, MouseEventArgs e) { try { MouseEventArgs me = (MouseEventArgs)e; if (!IsSelectedCategoryAllCategory && me.Button == MouseButtons.Right) { MenuItem mi; mi = new MenuItem("Delete Category: " + tabControl1.SelectedTab.Text); mi.Click += new EventHandler(mi_Delete_Click); var TabRightClickMenu = new System.Windows.Forms.ContextMenu(new MenuItem[] { mi }); TabRightClickMenu.GetContextMenu().Show(this, new Point(me.X + tabControl1.Location.X, me.Y + tabControl1.Location.Y)); } } catch (InvalidCastException) { // was apparently not a mouse click! } }
private void tabControl1_MouseClick( object sender, MouseEventArgs e ) { try { MouseEventArgs me = (MouseEventArgs)e; if ( !IsSelectedCategoryAllCategory && me.Button == MouseButtons.Right ) { MenuItem mi; mi = new MenuItem( "Delete Category: " + tabControl1.SelectedTab.Text ); mi.Click += new EventHandler( mi_Delete_Click ); var TabRightClickMenu = new System.Windows.Forms.ContextMenu( new MenuItem[] { mi } ); TabRightClickMenu.GetContextMenu().Show( this, new Point( me.X + tabControl1.Location.X, me.Y + tabControl1.Location.Y ) ); } } catch ( InvalidCastException ) { // was apparently not a mouse click! } }