Example #1
0
        private void listView_columns_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            ContextMenu contextMenu = new ContextMenu();
            MenuItem    menuItem    = null;

            menuItem        = new MenuItem("修改栏目 (&M)");
            menuItem.Click += new System.EventHandler(this.menu_modifyColumn_Click);
            if (this.listView_columns.SelectedItems.Count == 0)
            {
                menuItem.Enabled = false;
            }
            contextMenu.MenuItems.Add(menuItem);

            menuItem        = new MenuItem("创建栏目 (&C)");
            menuItem.Click += new System.EventHandler(this.menu_newColumn_Click);
            contextMenu.MenuItems.Add(menuItem);

            // ---
            menuItem = new MenuItem("-");
            contextMenu.MenuItems.Add(menuItem);

            menuItem        = new MenuItem("上移 (&U)");
            menuItem.Click += new System.EventHandler(this.menu_moveUpColumn_Click);
            if (ListViewUtil.MoveItemEnabled(this.listView_columns, true) == false)
            {
                menuItem.Enabled = false;
            }
            contextMenu.MenuItems.Add(menuItem);

            menuItem        = new MenuItem("下移 (&U)");
            menuItem.Click += new System.EventHandler(this.menu_moveDownColumn_Click);
            if (ListViewUtil.MoveItemEnabled(this.listView_columns, false) == false)
            {
                menuItem.Enabled = false;
            }
            contextMenu.MenuItems.Add(menuItem);

            // ---
            menuItem = new MenuItem("-");
            contextMenu.MenuItems.Add(menuItem);

            menuItem        = new MenuItem("删除 [" + this.listView_columns.SelectedItems.Count.ToString() + "] (&S)");
            menuItem.Click += new System.EventHandler(this.menu_deleteColumn_Click);
            if (this.listView_columns.SelectedItems.Count == 0)
            {
                menuItem.Enabled = false;
            }
            contextMenu.MenuItems.Add(menuItem);

            contextMenu.Show(this.listView_columns, new Point(e.X, e.Y));
        }
Example #2
0
        private void listView1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            ContextMenu contextMenu = new ContextMenu();
            MenuItem    menuItem    = null;

            bool bSelected = ListView.SelectedItems.Count > 0;

            //
            menuItem        = new MenuItem("修改(&M)");
            menuItem.Click += new System.EventHandler(this.menu_modifyServer);
            if (bSelected == false)
            {
                menuItem.Enabled = false;
            }
            contextMenu.MenuItems.Add(menuItem);


            // ---
            menuItem = new MenuItem("-");
            contextMenu.MenuItems.Add(menuItem);


            menuItem        = new MenuItem("删除(&D)");
            menuItem.Click += new System.EventHandler(this.menu_deleteServer);
            if (bSelected == false)
            {
                menuItem.Enabled = false;
            }
            contextMenu.MenuItems.Add(menuItem);

            // ---
            menuItem = new MenuItem("-");
            contextMenu.MenuItems.Add(menuItem);


            //
            menuItem        = new MenuItem("新增(&N)");
            menuItem.Click += new System.EventHandler(this.menu_newServer);
            contextMenu.MenuItems.Add(menuItem);

            // ---
            menuItem = new MenuItem("-");
            contextMenu.MenuItems.Add(menuItem);

            //
            menuItem        = new MenuItem("上移(&U)");
            menuItem.Click += new System.EventHandler(this.menu_up);
            if (ListViewUtil.MoveItemEnabled(this.ListView, true) == false)
            {
                menuItem.Enabled = false;
            }
            contextMenu.MenuItems.Add(menuItem);
            //
            menuItem        = new MenuItem("下移(&N)");
            menuItem.Click += new System.EventHandler(this.menu_down);
            if (ListViewUtil.MoveItemEnabled(this.ListView, false) == false)
            {
                menuItem.Enabled = false;
            }
            contextMenu.MenuItems.Add(menuItem);

            contextMenu.Show(ListView, new Point(e.X, e.Y));
        }