共用方式為


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
)

參數

  • e
    類型:EventArgs

    包含事件資料的 EventArgs

備註

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

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 命名空間

其他資源

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

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

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