Shape.OnContextMenuChanged 方法
引發 ContextMenuChanged 事件。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
Protected Overridable Sub OnContextMenuChanged ( _
e As EventArgs _
)
protected virtual void OnContextMenuChanged(
EventArgs e
)
protected:
virtual void OnContextMenuChanged(
EventArgs^ e
)
abstract OnContextMenuChanged :
e:EventArgs -> unit
override OnContextMenuChanged :
e:EventArgs -> unit
protected function OnContextMenuChanged(
e : EventArgs
)
參數
e
類型:EventArgs包含事件資料的 EventArgs。
備註
引發事件會透過委派叫用此事件處理常式。 如需詳細資訊,請參閱處理和引發事件。
OnContextMenuChanged方法也可讓衍生的類別來處理事件,而不用附加委派。 這是在衍生類別中處理事件的慣用技巧。
繼承者注意事項
當您覆寫OnContextMenuChanged在衍生類別中,請務必呼叫OnContextMenuChanged方法的基底類別,好讓註冊的委派可接收事件。
範例
下列範例是事件引發方法時執行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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
如何:使用 LineShape 控制項繪製線條 (Visual Studio)