开发者

C# WinForm up down drag click

开发者 https://www.devze.com 2023-01-21 01:43 出处:网络
How do I capture a left mouse clic开发者_C百科k , up/down/drag? What would the right mouse click be? Overriding OnMouseClick, OnMouseDown, or OnMouseUp would be the way to go.The MouseEventArgs class

How do I capture a left mouse clic开发者_C百科k , up/down/drag? What would the right mouse click be?


Overriding OnMouseClick, OnMouseDown, or OnMouseUp would be the way to go. The MouseEventArgs class can contains members which will help you figure out which button(s) were pressed.

Dragging is a different animal altogether. You need to override the OnDragEnter and OnDragDrop methods, and you will also need to initiate the drag-drop operation by calling DoDragDrop at the appropriate time.


try this:

private void FormA_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
            }
            else if (e.Button == MouseButtons.Right)
            {
            }
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号