【问题标题】:ContextMenuStrip Opening EventContextMenuStrip 开幕活动
【发布时间】:2017-02-17 22:16:52
【问题描述】:

我的项目中有一个 ContexMenuStrip cms。我正在尝试将此事件添加到我的代码中,但是当我右键单击鼠标时它没有触发。

出现菜单但未调用事件。

void cms_Opening(object sender, CancelEventArgs e)
    {
        // Code...
    }

我正在尝试处理此事件,以防止在某些条件满足时打开 cms。

感谢您的宝贵时间。

【问题讨论】:

  • 请附上完整代码

标签: contextmenustrip


【解决方案1】:

我认为这是相关代码。

 private void MenuTeam_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
    {            
        if (dgvMatches.CurrentCell != null && (dgvMatches.CurrentCell.ColumnIndex == 3 || dgvMatches.CurrentCell.ColumnIndex == 6))
        {
            dgvMatches.CurrentCell.Value = e.ClickedItem.ToString();
            dgvMatches.CurrentCell = null;
        }
    }
    private void MenuGolos_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
    {

        if (dgvMatches.CurrentCell != null && (dgvMatches.CurrentCell.ColumnIndex == 4 || dgvMatches.CurrentCell.ColumnIndex == 5))
        {
            dgvMatches.CurrentCell.Value = e.ClickedItem.ToString();
            dgvMatches.CurrentCell = null;
        }
    }


    void MenuGolos_Opening(object sender, CancelEventArgs e)
    {
        if (dgvMatches.CurrentCell.ColumnIndex != 4 || dgvMatches.CurrentCell.ColumnIndex != 5)
        {
            MenuGolos.Close();
        }
    }

前两个事件运行良好。第三个没有被触发。

谢谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-24
    • 1970-01-01
    • 2015-05-17
    相关资源
    最近更新 更多