ToolStripRenderEventArgs.ToolStrip Propiedad

Definición

Obtiene el ToolStrip que se va a pintar.

public:
 property System::Windows::Forms::ToolStrip ^ ToolStrip { System::Windows::Forms::ToolStrip ^ get(); };
public System.Windows.Forms.ToolStrip ToolStrip { get; }
member this.ToolStrip : System.Windows.Forms.ToolStrip
Public ReadOnly Property ToolStrip As ToolStrip

Valor de propiedad

ToolStrip

Objeto ToolStrip que se va a pintar.

Ejemplos

En el ejemplo de código siguiente se muestra cómo invalidar el OnRenderToolStripBackground método para pintar un degradado en segundo plano de un ToolStrip control. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la ToolStripRenderer clase .

// This method renders the GridStrip control's background.
protected override void OnRenderToolStripBackground(
    ToolStripRenderEventArgs e)
{
    base.OnRenderToolStripBackground(e);

    // This late initialization is a workaround. The gradient
    // depends on the bounds of the GridStrip control. The bounds 
    // are dependent on the layout engine, which hasn't fully
    // performed layout by the time the Initialize method runs.
    if (this.backgroundBrush == null)
    {
        this.backgroundBrush = new LinearGradientBrush(
           e.ToolStrip.ClientRectangle,
           SystemColors.ControlLightLight,
           SystemColors.ControlDark,
           90,
           true);
    }

    // Paint the GridStrip control's background.
    e.Graphics.FillRectangle(
        this.backgroundBrush, 
        e.AffectedBounds);
}
' This method renders the GridStrip control's background.
Protected Overrides Sub OnRenderToolStripBackground(e As ToolStripRenderEventArgs)
   MyBase.OnRenderToolStripBackground(e)
   
   ' This late initialization is a workaround. The gradient
   ' depends on the bounds of the GridStrip control. The bounds 
   ' are dependent on the layout engine, which hasn't fully
   ' performed layout by the time the Initialize method runs.
   If Me.backgroundBrush Is Nothing Then
      Me.backgroundBrush = New LinearGradientBrush(e.ToolStrip.ClientRectangle, SystemColors.ControlLightLight, SystemColors.ControlDark, 90, True)
   End If
   
   ' Paint the GridStrip control's background.
   e.Graphics.FillRectangle(Me.backgroundBrush, e.AffectedBounds)
  End Sub

Se aplica a

Consulte también