简体   繁体   中英

C# WinForm up down drag click

How do I capture a left mouse click , 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)
            {
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM