我如何检测,哪一个鼠标按键已经双击了形式,即左,右或中间?
How can I detect, which mouse button have double clicked the form i.e. Left, Right or Middle?
更新: 我使用的.NET2.0
Updated: I am using .NET2.0
存放在的MouseUp 事件最后点击的按钮,然后检查,在双击事件。样品code:
Store the last clicked button in MouseUp event and then check that in the double click event. Sample code:
MouseButtons _lastButtonUp = MouseButtons.None;
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
_lastButtonUp = e.Button;
}
private void Form1_DoubleClick(object sender, EventArgs e)
{
switch (_lastButtonUp)
{
case System.Windows.Forms.MouseButtons.Left:
MessageBox.Show("left double click");
break;
case System.Windows.Forms.MouseButtons.Right:
MessageBox.Show("right double click");
break;
case System.Windows.Forms.MouseButtons.Middle:
MessageBox.Show("middle double click");
break;
}
}