ToolStripRenderer.InitializeItem Method (ToolStripItem)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

When overridden in a derived class, provides for custom initialization of the given ToolStripItem.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

protected internal virtual void InitializeItem(
	ToolStripItem item


Type: System.Windows.Forms.ToolStripItem

The ToolStripItem to be initialized.

Use the InitializeItem method to set properties, such as the ToolStripItem.BackColor or ToolStripItem.Font, when a ToolStripItem is rendered.

The following code example demonstrates how to initialize individual ToolStripItem controls. This code example is part of a larger example provided for the ToolStripRenderer class.

// 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)

    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(

        // Assign the subimage to the ToolStripButton
        // control's Image property.
        item.Image = subImage;

.NET Framework
Available since 2.0
Return to top