共用方式為


Shape.MouseHover 事件

更新:2007 年 11 月

發生於滑鼠指標停留在形狀上時。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

<BrowsableAttribute(True)> _
Public Event MouseHover As EventHandler

Dim instance As Shape
Dim handler As EventHandler

AddHandler instance.MouseHover, handler
[BrowsableAttribute(true)]
public event EventHandler MouseHover
[BrowsableAttribute(true)]
public:
 event EventHandler^ MouseHover {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
JScript 不支援事件。

備註

MouseHover 的一般用法是,當滑鼠暫時停留在形狀周圍的指定區域 (「停留矩形」(Hover Rectangle) 中時,顯示工具提示。引發這個事件所需的暫停時間是由 MouseHoverTime 屬性所指定 (以毫秒為單位)。

MouseHover 事件的定義和偵測與 MouseHoverSizeMouseHoverTime 屬性有關。

滑鼠事件依下列順序發生:

MouseEnter

MouseMove

MouseHover / MouseDown / MouseWheel

MouseUp

MouseLeave

如需如何處理事件的詳細資訊,請參閱使用事件

範例

下列範例會在滑鼠移到圖案上時,在狀態列中顯示訊息。這個範例要求您的表單必須有一個名為 RectangleShape1 的 RectangleShape 控制項和一個名為 StatusStrip1 的 StatusStrip 控制項。StatusStrip 必須有一個名為 ToolStripStatusLabel1 的 ToolStripStatusLabel

Private Sub RectangleShape1_MouseEnter(ByVal sender As Object, _
 ByVal e As System.EventArgs) Handles RectangleShape1.MouseEnter
    ToolStripStatusLabel1.Text = "The mouse has entered the shape."
End Sub

Private Sub RectangleShape1_MouseHover(ByVal sender As Object, _
  ByVal e As System.EventArgs) Handles RectangleShape1.MouseHover
    ToolStripStatusLabel1.Text = "The mouse is paused over the shape."
End Sub

Private Sub RectangleShape1_MouseLeave(ByVal sender As Object, _
  ByVal e As System.EventArgs) Handles RectangleShape1.MouseLeave
    ToolStripStatusLabel1.Text = "The mouse has left the shape."
End Sub

Private Sub RectangleShape1_MouseMove(ByVal sender As Object, _
  ByVal e As System.Windows.Forms.MouseEventArgs) Handles _
  RectangleShape1.MouseMove
    ToolStripStatusLabel1.Text = "The mouse is over the shape."
End Sub
private void rectangleShape1_MouseEnter(object sender, System.EventArgs e)
{
    toolStripStatusLabel1.Text = "The mouse has entered the shape.";
}

private void rectangleShape1_MouseHover(object sender, System.EventArgs e)
{
    toolStripStatusLabel1.Text = "The mouse is paused over the shape.";
}

private void rectangleShape1_MouseLeave(object sender, System.EventArgs e)
{
    toolStripStatusLabel1.Text = "The mouse has left the shape.";
}

private void rectangleShape1_MouseMove(object sender, 
    System.Windows.Forms.MouseEventArgs e)
{
    toolStripStatusLabel1.Text = "The mouse is over the shape.";
}

使用權限

請參閱

參考

Shape 類別

Shape 成員

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)

HOW TO:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)

Line 和 Shape 控制項簡介 (Visual Studio)