共用方式為


Shape.OnMouseEnter 方法

引發 MouseEnter 事件。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

'宣告
Protected Friend Overridable Sub OnMouseEnter ( _
    e As EventArgs _
)
protected internal virtual void OnMouseEnter(
    EventArgs e
)
protected public:
virtual void OnMouseEnter(
    EventArgs^ e
)
abstract OnMouseEnter : 
        e:EventArgs -> unit  
override OnMouseEnter : 
        e:EventArgs -> unit
function OnMouseEnter(
    e : EventArgs
)

參數

  • e
    類型:EventArgs

    包含事件資料的 EventArgs

備註

引發事件會透過委派叫用此事件處理常式。 如需詳細資訊,請參閱處理和引發事件

OnMouseEnter方法也可讓衍生的類別來處理事件,而不用附加委派。 這是在衍生類別中處理事件的慣用技巧。

繼承者注意事項

當您覆寫OnMouseEnter在衍生類別中,請務必呼叫OnMouseEnter方法的基底類別,好讓註冊的委派可接收事件。

範例

下列範例是一種方法是執行時Click就會發生事件。 Shape類別有幾個方法名稱模式OnEventName執行方法時EventName就會發生事件。 (EventName代表對應的事件名稱。)

下列範例示範如何覆寫OnClickOnLostFocus從衍生類別中的方法LineShape

Public Class HighlightLine
    Inherits LineShape
    Protected Overrides Sub OnClick(ByVal e As EventArgs)
        ' Change the color of the line when clicked. 
        Me.BorderColor = Color.Red
        MyBase.OnClick(e)
    End Sub 
    Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs)
        ' Change the color of the line when focus is changed. 
        Me.BorderColor = Color.Black
        MyBase.OnLostFocus(e)
    End Sub 
End Class
public class HighlightLine :
    LineShape
{
    protected override void OnClick(EventArgs e)
    {
        // Change the color of the line when clicked. 
        this.BorderColor = Color.Red;
        base.OnClick(e);
    }
    protected override void OnLostFocus(System.EventArgs e)
    {
        // Change the color of the line when focus is changed. 
        this.BorderColor = Color.Black;
        base.OnLostFocus(e);
    }
}

.NET Framework 安全性

請參閱

參考

Shape 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)

Line 和 Shape 控制項簡介 (Visual Studio)