Dela via


Shape.MouseWheel Event

Occurs when the mouse wheel moves and the shape has focus.

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

Syntax

'Declaration
<BrowsableAttribute(True)> _
Public Event MouseWheel As MouseEventHandler
[BrowsableAttribute(true)]
public event MouseEventHandler MouseWheel
[BrowsableAttribute(true)]
public:
 event MouseEventHandler^ MouseWheel {
    void add (MouseEventHandler^ value);
    void remove (MouseEventHandler^ value);
}
[<BrowsableAttribute(true)>]
member MouseWheel : IEvent<MouseEventHandler,
    MouseEventArgs>
JScript does not support events.

Remarks

When handling the MouseWheel event, you should follow the user interface (UI) standards associated with the mouse wheel. The Delta property value indicates the amount the mouse wheel has been moved. The UI should scroll when the accumulated delta is plus or minus 120. The UI should scroll the number of logical lines returned by the MouseWheelScrollLines property for every delta value reached. You can also scroll more smoothly by using smaller than 120-unit increments. However, the ratio should remain constant, that is, MouseWheelScrollLines lines scrolled per 120 delta units of wheel movement.

Mouse events occur in the following order:

MouseEnter

MouseMove

MouseHover / MouseDown / MouseWheel

MouseUp

MouseLeave

For more information about how to handle events, see Consuming Events.

Examples

The following example shows how to use the MouseWheel event to scroll a RectangleShape control. This example requires that you have a RectangleShape control named RectangleShape1 on a form.

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

.NET Framework Security

See Also

Reference

Shape Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

How to: Draw Lines with the LineShape Control (Visual Studio)

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Introduction to the Line and Shape Controls (Visual Studio)