ToolStripRenderer.OnRenderToolStripBorder(ToolStripRenderEventArgs) ToolStripRenderer.OnRenderToolStripBorder(ToolStripRenderEventArgs) ToolStripRenderer.OnRenderToolStripBorder(ToolStripRenderEventArgs) ToolStripRenderer.OnRenderToolStripBorder(ToolStripRenderEventArgs) Method

定義

引發 RenderToolStripBorder 事件。Raises the RenderToolStripBorder event.

protected:
 virtual void OnRenderToolStripBorder(System::Windows::Forms::ToolStripRenderEventArgs ^ e);
protected virtual void OnRenderToolStripBorder (System.Windows.Forms.ToolStripRenderEventArgs e);
abstract member OnRenderToolStripBorder : System.Windows.Forms.ToolStripRenderEventArgs -> unit
override this.OnRenderToolStripBorder : System.Windows.Forms.ToolStripRenderEventArgs -> unit
Protected Overridable Sub OnRenderToolStripBorder (e As ToolStripRenderEventArgs)

參數

範例

下列程式碼範例示範如何覆寫 OnRenderToolStripBorder 方法,以在 @no__t 1 控制項周圍繪製自訂框線。The following code example demonstrates how to override the OnRenderToolStripBorder method to draw a custom border around a ToolStrip control. 這個程式碼範例是針對 ToolStripRenderer 類別所提供的較大範例的一部分。This code example is part of a larger example provided for the ToolStripRenderer class.

// This method draws a border around the GridStrip control.
protected override void OnRenderToolStripBorder(
    ToolStripRenderEventArgs e)
{
    base.OnRenderToolStripBorder(e);

    ControlPaint.DrawFocusRectangle(
        e.Graphics,
        e.AffectedBounds,
        SystemColors.ControlDarkDark,
        SystemColors.ControlDarkDark);
}
' This method draws a border around the GridStrip control.
Protected Overrides Sub OnRenderToolStripBorder(e As ToolStripRenderEventArgs)
   MyBase.OnRenderToolStripBorder(e)
   
   ControlPaint.DrawFocusRectangle(e.Graphics, e.AffectedBounds, SystemColors.ControlDarkDark, SystemColors.ControlDarkDark)
End Sub 

備註

引發事件會透過委派叫用此事件處理常式。Raising an event invokes the event handler through a delegate. 如需詳細資訊,請參閱處理和引發事件For more information, see Handling and Raising Events.

OnRenderToolStripBorder 方法也允許衍生類別處理事件,而不用附加委派。The OnRenderToolStripBorder method also allows derived classes to handle the event without attaching a delegate. 這是在衍生類別中處理事件的慣用技巧。This is the preferred technique for handling the event in a derived class.

給繼承者的注意事項

當在衍生類別中覆寫 OnRenderToolStripBorder(ToolStripRenderEventArgs) 時,請確定呼叫基底類別的 OnRenderToolStripBorder(ToolStripRenderEventArgs) 方法,使已註冊的委派能接收到事件。When overriding OnRenderToolStripBorder(ToolStripRenderEventArgs) in a derived class, be sure to call the base class's OnRenderToolStripBorder(ToolStripRenderEventArgs) method so that registered delegates receive the event.

適用於

另請參閱