ToolStripItem.MouseEnter 事件


發生於滑鼠指標進入此項目時。Occurs when the mouse pointer enters the item.

 event EventHandler ^ MouseEnter;
public event EventHandler MouseEnter;
member this.MouseEnter : EventHandler 
Public Custom Event MouseEnter As EventHandler 


下列程式碼範例示範如何使用這個成員。The following code example demonstrates the use of this member. 在此範例中,事件處理常式會報告 MouseEnter 事件的發生。In the example, an event handler reports on the occurrence of the MouseEnter event. 此報表可協助您瞭解事件發生的時間,並可協助您進行調試。This report helps you to learn when the event occurs and can assist you in debugging. 若要報告多個事件或經常發生的事件,請考慮使用 Console.WriteLine 取代 MessageBox.Show,或將訊息附加到多行 TextBoxTo report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.

若要執行範例程式碼,請將它貼入包含繼承自 ToolStripItem之類型實例的專案,例如 ToolStripButtonToolStripMenuItemTo run the example code, paste it into a project that contains an instance of a type that inherits from ToolStripItem, such as a ToolStripButton or ToolStripMenuItem. 然後將實例命名為 ToolStripItem1,並確定事件處理常式與 MouseEnter 事件相關聯。Then name the instance ToolStripItem1 and ensure that the event handler is associated with the MouseEnter event.

private void ToolStripItem1_MouseEnter(Object sender, EventArgs e) {

   MessageBox.Show("You are in the ToolStripItem.MouseEnter event.");

Private Sub ToolStripItem1_MouseEnter(sender as Object, e as EventArgs) _ 
     Handles ToolStripItem1.MouseEnter

   MessageBox.Show("You are in the ToolStripItem.MouseEnter event.")

End Sub


滑鼠事件依下列順序發生:Mouse events occur in the following order:

  1. MouseEnter

  2. MouseMove

  3. MouseHoverMouseDownMouseHover or MouseDown

  4. MouseUp

  5. MouseLeave

如需處理事件的詳細資訊,請參閱處理和引發事件For more information about handling events, see Handling and Raising Events.