ToolStripRenderer.InitializeItem(ToolStripItem) ToolStripRenderer.InitializeItem(ToolStripItem) ToolStripRenderer.InitializeItem(ToolStripItem) ToolStripRenderer.InitializeItem(ToolStripItem) Method

定義

派生クラスでオーバーライドすると、特定の ToolStripItem のカスタムの初期化処理を提供します。When overridden in a derived class, provides for custom initialization of the given ToolStripItem.

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)

パラメーター

item
ToolStripItem ToolStripItem ToolStripItem ToolStripItem

初期化する ToolStripItemThe ToolStripItem to be initialized.

次のコード例は、個々の ToolStripItem コントロールを初期化する方法を示しています。The following code example demonstrates how to initialize individual ToolStripItem controls. このコード例は、@no__t 0 クラス用に提供されている大規模な例の一部です。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)
{
    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 

注釈

@No__t-0 メソッドを使用して、ToolStripItem がレンダリングされるときに ToolStripItem.BackColorToolStripItem.Font などのプロパティを設定します。Use the InitializeItem method to set properties, such as the ToolStripItem.BackColor or ToolStripItem.Font, when a ToolStripItem is rendered.

適用対象

こちらもご覧ください