共用方式為


Shape.OnEnabledChanged 方法

引發 EnabledChanged 事件。

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

語法

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

參數

備註

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

OnEnabledChanged 方法也允許衍生類別處理事件,而不用附加委派。這是在衍生類別中處理事件的慣用技術。

繼承者注意事項

覆寫衍生類別中的 OnEnabledChanged 時,請務必呼叫基底類別的 OnEnabledChanged 方法,如此登錄的委派才能接收事件。

範例

下列範例是事件引發方法的執行時機Enabled屬性值變更。Shape類別有幾個方法具有名模式OnPropertyNameChanged ,引發對應的 PropertyNameChanged事件時 PropertyName 值的變更。(PropertyName 表示對應的屬性名稱。)

下列範例會變更線條的色彩時Enabled屬性的類別衍生自LineShape變更為false。

Public Class DisabledLine
    Inherits LineShape
    Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
        ' Change the color of the line when selected.
        If Me.BorderColor = SystemColors.InactiveBorder Then
            Me.BorderColor = Color.Black
        Else
            Me.BorderColor = SystemColors.InactiveBorder
        End If
        MyBase.OnEnabledChanged(e)
    End Sub
End Class
public class DisabledLine :
    LineShape
{
    protected override void OnEnabledChanged(EventArgs e)
    {
        // Change the color of the line when selected.
        if (this.BorderColor == SystemColors.InactiveBorder)
        {
            this.BorderColor = Color.Black;
        }
        else
        {
            this.BorderColor = SystemColors.InactiveBorder;
        }
        base.OnEnabledChanged(e);
    }
}

.NET Framework 安全性

請參閱

參考

Shape 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)

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

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