ToolStripRenderer.InitializeItem Method

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

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

protected internal virtual void InitializeItem (
	ToolStripItem item
protected void InitializeItem (
	ToolStripItem item
protected internal function InitializeItem (
	item : ToolStripItem
Not applicable.



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;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions