Web应用程序中C#中的鼠标右键单击选项 [英] mouse right click options in c# in web application
本文介绍了Web应用程序中C#中的鼠标右键单击选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过在网格视图上单击鼠标右键,它应该在Web应用程序中显示呼叫,电子邮件选项吗?
By clicking right button from mouse on the gridview it should display call, email options in web application?
推荐答案
将鼠标单击事件附加到特定控件,或者您可以通过表单的Controls集合通过迭代编写一些附加到所有控件的内容.
Attaching mouse click event to specific controls or you can write something to attach to all controls by iteration through the form''s Controls collection.
label1.MouseClick += new MouseEventHandler(control_RightMouseClick);
gridview1.MouseClick += new MouseEventHandler(control_RightMouseClick);
然后执行不同的操作或为不同的控件显示不同的上下文菜单
Then perform different operations or show different context menu for different controls
if (e.Button != MouseButtons.Right)
{
return;
}
if (sender.GetType().IsSubclassOf(typeof(Control)))
{
Control formControl = (Control)sender;
switch (formControl.Name)
{
case "label1":
//do something
contextMenuStrip1.Show(formControl, e.Location);
break;
case "gridview1":
//do something else
contextMenuStrip2.Show(formControl, e.Location);
break;
default:
//do something else or return or show default context menu
contextMenuStrip_default.Show(formControl, e.Location);
break;
}
}
return;
这篇关于Web应用程序中C#中的鼠标右键单击选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文