gpt4 book ai didi

c# - 如何在 C# 中创建右键单击事件处理程序

转载 作者:太空宇宙 更新时间:2023-11-03 18:31:14 25 4
gpt4 key购买 nike

我想知道如何在您右键单击窗口时显示上下文菜单。

到目前为止,这是我的代码:

private void ShowContextMenu_RightClick(object sender, EventArgs e)
{
toolStripMenuItem5.Visible = true;
}
private void toolStripMenuItem5_Click(object sender, EventArgs e)
{
MessageBox.Show("Hi there this is my 3rd app which is *animation*.", "Programmed by D & K");
}

最佳答案

据我所知,winforms 中没有直接的 RightClick 事件。您可以使用 mousedown 事件来实现此目的

  private void toolStripButton1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
MessageBox.Show("Hi there this is my 3rd app which is *animation*.", "Programed by D & K");
}
}

关于c# - 如何在 C# 中创建右键单击事件处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22126528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com