/// <summary> /// Print the menu when the user do a right click /// </summary> /// <param name="Sender"></param> /// <param name="E"></param> private void ListView_MouseUp(object Sender, MouseEventArgs E) { if (E.Button == MouseButtons.Right && ListView.SelectedItems.Count != 0) { RightClickMenuStrip.Items.Clear(); RightClickMenuStrip.Items.Add("Ajouter"); RightClickMenuStrip.Items.Add("Modifier"); RightClickMenuStrip.Items.Add("Supprimer"); RightClickMenuStrip.Show(this, new Point(E.X + 14, E.Y + 4)); } else if (E.Button == MouseButtons.Right && ListView.SelectedItems.Count == 0) { RightClickMenuStrip.Items.Clear(); RightClickMenuStrip.Items.Add("Ajouter"); RightClickMenuStrip.Show(this, new Point(E.X + 14, E.Y + 4)); } }
/************************************************************************* * ************************** Add Tab Page ******************************* * **********************************************************************/ // determines the tab has been clicked protected void tabControl1_MouseDown(object sender, MouseEventArgs e) { var lastIndex = this.tabControl1.TabCount - 1; if (this.tabControl1.GetTabRect(lastIndex).Contains(e.Location)) { CreateNewTab(); } // right click on tab if (e.Button == MouseButtons.Right) { for (int i = 0; i < tabControl1.TabCount; i++) { Rectangle r = tabControl1.GetTabRect(i); if (r.Contains(e.Location)) { RightClickMenuStrip.Show(this, new Point(e.X, e.Y)); selectedTabPage = tabControl1.TabPages[i]; } } } }