如何判断当前鼠标是否按下左键或右键
1个回答
展开全部
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.CenterToScreen();
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && e.Clicks == 1)
{
this.label1.Text = "您单击了鼠标左键!";
}
else if (e.Button == MouseButtons.Right && e.Clicks == 1)
{
this.label1.Text = "您单击了鼠标右键!";
}
}
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && e.Clicks == 2)
{
this.label1.Text = "您双击了鼠标左键!";
}
else if (e.Button == MouseButtons.Right && e.Clicks == 2)
{
this.label1.Text = "您双击了鼠标右键!";
}
}
}
这样可以判断是鼠标左键还是右键了
{
public Form1()
{
InitializeComponent();
this.CenterToScreen();
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && e.Clicks == 1)
{
this.label1.Text = "您单击了鼠标左键!";
}
else if (e.Button == MouseButtons.Right && e.Clicks == 1)
{
this.label1.Text = "您单击了鼠标右键!";
}
}
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && e.Clicks == 2)
{
this.label1.Text = "您双击了鼠标左键!";
}
else if (e.Button == MouseButtons.Right && e.Clicks == 2)
{
this.label1.Text = "您双击了鼠标右键!";
}
}
}
这样可以判断是鼠标左键还是右键了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询