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)

public event MouseEventHandler MouseWheel

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:



MouseHover / MouseDown / MouseWheel



For more information about how to handle events, see Handling and Raising Events.

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

Return to top