ToolStripRenderer.InitializeItem(ToolStripItem) 메서드

정의

파생 클래스에서 재정의된 경우 지정된 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 컨트롤을 초기화하는 방법을 보여 줍니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 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

설명

메서드를 InitializeItem 사용하여 렌더링될 때 ToolStripItem 또는 ToolStripItem.Font같은 ToolStripItem.BackColor 속성을 설정합니다.

적용 대상

추가 정보