Shape.MouseEnter 事件

更新:2007 年 11 月

当鼠标指针进入形状时发生。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
<BrowsableAttribute(True)> _
Public Event MouseEnter As EventHandler
用法
Dim instance As Shape
Dim handler As EventHandler

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

备注

鼠标事件按以下顺序发生:

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 命名空间

其他资源

如何:使用 LineShape 控件绘制直线 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)

Line 和 Shape 控件简介 (Visual Studio)