ToolStripRenderer.InitializeItem(ToolStripItem) Método

Definición

Cuando se reemplaza en una clase derivada, proporciona una inicialización personalizada del objeto ToolStripItem especificado.

protected public:
 virtual void InitializeItem(System::Windows::Forms::ToolStripItem ^ item);
protected internal virtual void InitializeItem (System.Windows.Forms.ToolStripItem item);
abstract member InitializeItem : System.Windows.Forms.ToolStripItem -> unit
override this.InitializeItem : System.Windows.Forms.ToolStripItem -> unit
Protected Friend Overridable Sub InitializeItem (item As ToolStripItem)

Parámetros

item
ToolStripItem

El objeto ToolStripItem que se va a inicializar.

Ejemplos

En el ejemplo de código siguiente se muestra cómo inicializar controles individuales ToolStripItem . Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase ToolStripRenderer.

// This method initializes an individual ToolStripButton
// control. It copies a subimage from the GridStripRenderer's
// main image, according to the position and size of 
// the ToolStripButton.
protected override void InitializeItem(ToolStripItem item)
{
    base.InitializeItem(item);

    GridStrip gs = item.Owner as GridStrip;

    // The empty cell does not receive a subimage.
    if ((item is ToolStripButton) &&
        (item != gs.EmptyCell))
    {
        // Copy the subimage from the appropriate 
        // part of the main image.
        Bitmap subImage = bmp.Clone(
            item.Bounds,
            PixelFormat.Undefined);

        // Assign the subimage to the ToolStripButton
        // control's Image property.
        item.Image = subImage;
    }
}
' This method initializes an individual ToolStripButton
' control. It copies a subimage from the GridStripRenderer's
' main image, according to the position and size of 
' the ToolStripButton.
Protected Overrides Sub InitializeItem(item As ToolStripItem)
   MyBase.InitializeItem(item)
   
      Dim gs As GridStrip = item.Owner
   
   ' The empty cell does not receive a subimage.
      If ((TypeOf (item) Is ToolStripButton) And _
           (item IsNot gs.EmptyCell)) Then
          ' Copy the subimage from the appropriate 
          ' part of the main image.
          Dim subImage As Bitmap = bmp.Clone(item.Bounds, PixelFormat.Undefined)

          ' Assign the subimage to the ToolStripButton
          ' control's Image property.
          item.Image = subImage
      End If
End Sub

Comentarios

Use el InitializeItem método para establecer propiedades, como o ToolStripItem.BackColorToolStripItem.Font, cuando se representa .ToolStripItem

Se aplica a

Consulte también