直接用窗体的click和doubleclick事件相应函数是没办法区分的,因为click在doubleclick前面被触发。
办法一:
在mousedown事件中处理,通过timer计算两次单击时间差。
private bool isFirstClick = true;
private bool isDoubleClick = false;
private int milliseconds = 0;
private Rectangle hitTestRectangle = new Rectangle();
private Rectangle doubleClickRectangle = new Rectangle();
// Detect a valid single click or double click.
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
// Verify that the mouse click is in the main hit
// test rectangle.
//if (!hitTestRectangle.Contains(e.Location))
{
// return;
}
// This is the first mouse click.
if (isFirstClick)
{
isFirstClick = false;
// Determine the location and size of the