更新:2007 年 11 月
發生於滑鼠指標位於形狀上方,並放開滑鼠按鈕時。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
<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);
}
JScript 不支援事件。
備註
滑鼠事件依下列順序發生:
MouseHover / MouseDown / MouseWheel
MouseUp
如需如何處理事件的詳細資訊,請參閱使用事件。
範例
下列範例顯示如何使用 MouseDown、MouseMove 和 MouseUp 事件,在 RectangleShape 控制項上繪製線條。這個範例要求您的表單必須有一個名為 RectangleShape1 的 RectangleShape 控制項。
Private mousePath = New System.Drawing.Drawing2D.GraphicsPath()
Private Sub RectangleShape2_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles _
RectangleShape2.MouseDown
Dim mouseDownLocation As 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)
End Sub
Private Sub RectangleShape2_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles RectangleShape2.MouseMove
Dim mouseX As Integer = e.X + RectangleShape2.Left
Dim mouseY As Integer = e.Y + RectangleShape2.Top
' Add a line to the graphics path.
mousePath.AddLine(mouseX, mouseY, mouseX, mouseY)
End Sub
Private Sub RectangleShape2_MouseUp(ByVal sender As Object, _
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()
End Sub
Private Sub RectangleShape2_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles RectangleShape2.Paint
' Draw the line.
e.Graphics.DrawPath(System.Drawing.Pens.DarkRed, mousePath)
End Sub
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.Dispose();
mousePath = new System.Drawing.Drawing2D.GraphicsPath();
rectangleShape2.Invalidate();
// 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.
rectangleShape2.Invalidate();
}
private void rectangleShape2_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
// Draw the line.
e.Graphics.DrawPath(System.Drawing.Pens.DarkRed, mousePath);
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)
HOW TO:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)