方法: Windows フォーム内の ToolStrip テキストとイメージの外観を変更する

ToolStripItem にテキストと画像を表示するかどうかや、それらの要素間、および ToolStrip に対する相対的な配置方法を制御できます。

ToolStripItem に表示される内容を定義するには

  • DisplayStyle プロパティを目的の値に設定します。 設定できる値は、ImageImageAndTextNone、および Text です。 既定値は、ImageAndText です。

    ToolStripButton2.DisplayStyle = _  
        System.Windows.Forms.ToolStripItemDisplayStyle.Image  
    
    toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;  
    

ToolStripItem のテキストの配置を設定するには

  • TextAlign プロパティを目的の値に設定します。 設定できる値は、上、中央、下と、左、中央、右の任意の組み合わせです。 既定値は、MiddleCenter です。

    ToolStripSplitButton1.TextAlign = _  
        System.Drawing.ContentAlignment.MiddleRight  
    
    toolStripSplitButton1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;  
    

ToolStripItem 上の画像の配置を設定するには

  • ImageAlign プロパティを目的の値に設定します。 設定できる値は、上、中央、下と、左、中央、右の任意の組み合わせです。 既定値は、MiddleLeft です。

    ToolStripSplitButton1.ImageAlign = _  
        System.Drawing.ContentAlignment.MiddleRight  
    
    toolStripSplitButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;  
    

ToolStripItem のテキストと画像間での相対的な表示位置を定義するには

  • TextImageRelation プロパティを目的の値に設定します。 設定できる値は、ImageAboveTextImageBeforeTextOverlayTextAboveImage、および TextBeforeImage です。 既定値は、ImageBeforeText です。

    ToolStripButton1.TextImageRelation = _  
        System.Windows.Forms.TextImageRelation.ImageAboveText  
    
    toolStripButton1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;  
    

関連項目