怎样在 OnMouseDown 中编写双击事件

解决方案 »

  1.   

    OnMouseDown() 改成 OnDoubleClick()
      

  2.   


     private void TextBoxMouseDownHandler(object sender, MouseEventArgs e)
      {
       if(DateTime.Now < gridMouseDownTime.AddMilliseconds(SystemInformation.DoubleClickTime))
       {
         MessageBox.Show("双击事件发生。鼠标双击到的值");
         
        //注意应该在什么时候给gridMouseDownTime值, 它的值为双击时第一下的时间   }
        }
      

  3.   

    我只想在 OnMouseDown 中实现
      

  4.   

    OnDoubleClick()啊
    你想表达什么意思啊。
      

  5.   

    楼主说"我只想在 OnMouseDown 中实现"是不是你想自己写一个事件啊,有些歧义。如果是自己想写,首先定义一个委托(可以直接用系统的),然后定义他的实例,只不过在之前加event关键定,在你想要触发的地方把委托写上就可以了,可以查看MSDN
      

  6.   

    楼主是不是想在OnMouseDown事件中触发OnDoubleClick()????????
      

  7.   

    [DllImport("User32.dll", CharSet=CharSet.Auto)]
    public static extern bool GetMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax);
    Win32.MSG msg = new Win32.MSG();
    WindowsAPI.GetMessage(ref msg, 0, 0, 0)
    switch(msg.message)
    {
       case (int)Msg.WM_MOUSEMOVE:
       {
        }
    .......................
    .....................
    ........
    }
    用它的返回值来响应双击时的事件和单击时的事件但又不屏蔽单击事件
     用OnDoubleClick()屏蔽我的单击事件
    请问如何编双击事件
      

  8.   

    俺是这样做的,能够权且实现
    private void listView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
      if(e.Clicks==2&&e.Button==MouseButtons.Left)
    {
    ListView lv=((ListView)sender);
    string str=lv.GetItemAt(e.X,e.Y).Text.ToString();
    MessageBox.Show(str);
    }
    }
      

  9.   

    OnMouseDown() 改成 OnDoubleClick()
      

  10.   

    不能改,OnDoubleClick()中不能获得鼠标位置
      

  11.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=C83C3A4B-8571-4CE6-FBAC-35DC28D14389
      

  12.   

    guyan033(古) 的方法不错,没想到还可以用系统的双击时间来判断....高...学习了..