Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MouseUp Event

Shape.MouseUp Event

Occurs when the mouse pointer is over the shape and a mouse button is released.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

public event MouseEventHandler MouseUp

Mouse events occur in the following order:



MouseHover / MouseDown / MouseWheel



For more information about how to handle events, see Consuming Events.

The following example shows how to use the MouseDown, MouseMove, and MouseUp events to draw lines on a RectangleShape control. This example requires that you have a RectangleShape control named RectangleShape1 on a form.

private System.Drawing.Drawing2D.GraphicsPath mousePath = 
    new System.Drawing.Drawing2D.GraphicsPath();

private void rectangleShape2_MouseDown(object sender, 
    System.Windows.Forms.MouseEventArgs e)
    Point mouseDownLocation = new Point(e.X + rectangleShape2.Left, 
        e.Y + rectangleShape2.Top);
    // Clear the previous line.
    mousePath = new System.Drawing.Drawing2D.GraphicsPath();
    // Add a line to the graphics path.
    mousePath.AddLine(mouseDownLocation, mouseDownLocation);

private void rectangleShape2_MouseMove(object sender, 
    System.Windows.Forms.MouseEventArgs e)
    int mouseX = e.X + rectangleShape2.Left;
    int mouseY = e.Y + rectangleShape2.Top;
    // Add a line to the graphics path.
    mousePath.AddLine(mouseX, mouseY, mouseX, mouseY);

private void rectangleShape2_MouseUp(object sender, 
    System.Windows.Forms.MouseEventArgs e)
    System.Drawing.Point mouseUpLocation = 
        new System.Drawing.Point(e.X + rectangleShape2.Left, 
            e.Y + rectangleShape2.Top);
    // Add a line to the graphics path.
    mousePath.AddLine(mouseUpLocation, mouseUpLocation);
    // Force the shape to redraw.

private void rectangleShape2_Paint(object sender, 
    System.Windows.Forms.PaintEventArgs e)
    // Draw the line.
    e.Graphics.DrawPath(System.Drawing.Pens.DarkRed, mousePath);

© 2015 Microsoft