Ejemplo n.º 1
0
 /// <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));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// To recover the selection of the user when he did a right click
        /// </summary>
        /// <param name="Sender"></param>
        /// <param name="E"></param>
        private void RightClickMenuStrip_ItemClicked(object Sender, ToolStripItemClickedEventArgs E)
        {
            RightClickMenuStrip.Close();
            switch (E.ClickedItem.Text)
            {
            case "Ajouter":
                AddObjectListView();
                break;

            case "Modifier":
                UpdateObjectListView();
                break;

            case "Supprimer":
                DeleteObjectListView();
                break;
            }
        }
Ejemplo n.º 3
0
        /*************************************************************************
         * ************************** 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];
                    }
                }
            }
        }