Jer*_*rry 0 c# toolstripitem toolstrip winforms
我有一个带有上下文菜单的工具条和一个带有click事件的工具条按钮.最初我尝试将上下文菜单分配给按钮本身,但在其属性中找不到上下文菜单.所以我将上下文菜单分配给了工具条.现在,只要我右键单击上下文菜单的按钮,就会触发按钮单击事件.我想检查点击了哪个鼠标按钮,所以我厌倦了将事件参数转换为mouseeventargs:
if (((MouseEventArgs)e).Button != MouseButtons.Left) return;
Run Code Online (Sandbox Code Playgroud)
但我有一个例外,我不能做这个演员.我可以为按钮指定上下文菜单或检测单击哪个鼠标按钮吗?谢谢
你可以尝试这样的MouseDown
事件ToolStripButton
:
private void toolStripButton1_MouseDown(object sender, MouseEventArgs e){
if(e.Button == MouseButtons.Right){
//...
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1639 次 |
最近记录: |