Shape.MouseWheel 事件

更新:2007 年 11 月

当移动鼠标滚轮且形状具有焦点时发生。

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

语法

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

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

备注

处理 MouseWheel 事件时,应该遵循与鼠标滚轮相关联的用户界面 (UI) 标准。 Delta 属性值指示鼠标轮的移动量。 当累积增量为正的或负的 120 时,UI 应滚动。对于达到的每个增量值,UI 应滚动 MouseWheelScrollLines 属性返回的逻辑行数。 还可以使用小于 120 个单位的增量来更平滑地滚动。 但是,该比率应保持恒定,即滚轮每移动 120 个单位的增量,就滚动 MouseWheelScrollLines 行。

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

MouseEnter

MouseMove

MouseHover / MouseDown / MouseWheel

MouseUp

MouseLeave

有关如何处理事件的更多信息,请参见使用事件

示例

下面的示例演示如何使用 MouseWheel 事件滚动 RectangleShape 控件。 此示例要求窗体上有一个名为 RectangleShape1 的 RectangleShape 控件。

Private Sub RectangleShape1_MouseWheel(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.MouseEventArgs) _
 Handles RectangleShape1.MouseWheel
    ' Move the shape vertically to correspond to the scrolling of the
    ' mouse wheel.
    Dim scale As Integer = e.Delta * _
      SystemInformation.MouseWheelScrollLines / 120
    RectangleShape1.Top = RectangleShape1.Top - scale
End Sub
private void rectangleShape1_MouseWheel(object sender, 
    System.Windows.Forms.MouseEventArgs e)
{
    // Move the shape vertically to correspond to the scrolling of the
    // mouse wheel.
    int scale = e.Delta * SystemInformation.MouseWheelScrollLines / 120;
    rectangleShape1.Top = rectangleShape1.Top - scale;
}

权限

另请参见

参考

Shape 类

Shape 成员

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

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

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

Line 和 Shape 控件简介 (Visual Studio)