更新: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 行。
滑鼠事件依下列順序發生:
MouseHover / MouseDown / MouseWheel
如需如何處理事件的詳細資訊,請參閱使用事件。
範例
下列範例說明如何使用 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;
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)
HOW TO:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)