示例#1
0
        void lg_ColumnRightClick(object sender, ColumnClickEventArgs e)
        {
            ListGroup lg = (ListGroup)sender;

            // Tuck the Active ListGroup into the Tag property:
            _ListGroupContextMenu.Tag = lg;

            // If the header is right-clicked, the user has not indicated an item to edit or delete.
            // Disable those options:
            _editOption.Enabled   = false;
            _deleteOption.Enabled = false;

            // Because we are not using the GroupedList's own ContextMenuStrip,
            // we need to use the PointToClient method so that the menu appears
            // in the correct position relative to the control:
            _ListGroupContextMenu.Show(lg, lg.PointToClient(MousePosition));
        }
示例#2
0
        void lg_MouseClick(object sender, MouseEventArgs e)
        {
            ListGroup lg = (ListGroup)sender;

            ListViewHitTestInfo info = lg.HitTest(e.X, e.Y);
            ListViewItem        item = info.Item;

            if (e.Button == MouseButtons.Right)
            {
                // Tuck the Active ListGroup into the Tag property:
                _ListGroupContextMenu.Tag = lg;

                // Make sure the Delete and Edit options are enabled:
                _editOption.Enabled   = true;
                _deleteOption.Enabled = true;

                // Because we are not using the GroupedList's own ContextMenuStrip,
                // we need to use the PointToClient method so that the menu appears
                // in the correct position relative to the control:
                _ListGroupContextMenu.Show(lg, lg.PointToClient(MousePosition));
            }
        }