Partilhar via


Evento Shape.MouseUp

Ocorre quando o ponteiro do mouse está sobre a forma e um botão do mouse é liberado.

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

Sintaxe

<BrowsableAttribute(True)> _
Public Event MouseUp As MouseEventHandler

Dim instance As Shape
Dim handler As MouseEventHandler

AddHandler instance.MouseUp, handler
[BrowsableAttribute(true)]
public event MouseEventHandler MouseUp
[BrowsableAttribute(true)]
public:
 event MouseEventHandler^ MouseUp {
    void add (MouseEventHandler^ value);
    void remove (MouseEventHandler^ value);
}
O JScript não oferece suporte a eventos.

Comentários

Eventos mouse ocorrem na seguinte ordem:

MouseEnter

MouseMove

MouseHover / MouseDown / MouseWheel

MouseUp

MouseLeave

Para obter mais informações sobre como lidar com eventos, consulte Consumindo Eventos.

Exemplos

O exemplo a seguir mostra como usar o MouseDown, MouseMove, e MouseUp eventos para desenhar linhas em uma RectangleShape controle. Este exemplo requer que você tenha um RectangleShape controle chamado RectangleShape1 em um formulário.

Private mousePath = New System.Drawing.Drawing2D.GraphicsPath()

PrivateSub RectangleShape2_MouseDown(ByVal sender AsObject, _
  ByVal e As System.Windows.Forms.MouseEventArgs) Handles _
  RectangleShape2.MouseDown
    Dim mouseDownLocation AsNew Point(e.X + RectangleShape2.Left, _
      e.Y + RectangleShape2.Top)
    ' Clear the previous line.
    mousePath.Dispose()
    mousePath = New System.Drawing.Drawing2D.GraphicsPath()
    RectangleShape2.Invalidate()
    ' Add a line to the graphics path.
    mousePath.AddLine(mouseDownLocation, mouseDownLocation)
EndSubPrivateSub RectangleShape2_MouseMove(ByVal sender AsObject, _
  ByVal e As System.Windows.Forms.MouseEventArgs) _
  Handles RectangleShape2.MouseMove
    Dim mouseX AsInteger = e.X + RectangleShape2.Left
    Dim mouseY AsInteger = e.Y + RectangleShape2.Top
    ' Add a line to the graphics path.
    mousePath.AddLine(mouseX, mouseY, mouseX, mouseY)
EndSubPrivateSub RectangleShape2_MouseUp(ByVal sender AsObject, _
  ByVal e As System.Windows.Forms.MouseEventArgs) _
  Handles RectangleShape2.MouseUp
    Dim 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.
    RectangleShape2.Invalidate()
EndSubPrivateSub RectangleShape2_Paint(ByVal sender AsObject, _
  ByVal e As System.Windows.Forms.PaintEventArgs) _
  Handles RectangleShape2.Paint
    ' Draw the line.
    e.Graphics.DrawPath(System.Drawing.Pens.DarkRed, mousePath)
EndSub
private System.Drawing.Drawing2D.GraphicsPath mousePath = 
    new System.Drawing.Drawing2D.GraphicsPath();

privatevoid 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.Dispose();
    mousePath = new System.Drawing.Drawing2D.GraphicsPath();
    rectangleShape2.Invalidate();
    // Add a line to the graphics path.
    mousePath.AddLine(mouseDownLocation, mouseDownLocation);
}

privatevoid 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);
}

privatevoid 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.
    rectangleShape2.Invalidate();
}

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

Permissões

Consulte também

Referência

Shape Classe

Membros Shape

Namespace Microsoft.VisualBasic.PowerPacks

Outros recursos

Como: Desenhar linhas com o Controlarar de LineShape (Visual Studio)

Como: Desenhar formas com a OvalShape e controles de RectangleShape (Visual Studio)

Introdução à linha e controles de forma (Visual Studio)