可以控制文本和图像是否显示在 ToolStripItem 上,并调整它们相对于彼此以及 ToolStrip 的对齐方式。
定义 ToolStripItem 上显示的内容
将 DisplayStyle 属性设置为所需的值。 可能性是
Image
,ImageAndText
None
和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 属性设置为所需的值。 可能性是
ImageAboveText
、ImageBeforeText
、Overlay
和TextAboveImage
TextBeforeImage
。 默认值为ImageBeforeText
。ToolStripButton1.TextImageRelation = _ System.Windows.Forms.TextImageRelation.ImageAboveText
toolStripButton1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;