ToolStripItem.TextAlign 属性

定义

获取或设置 ToolStripLabel 上的文本的对齐方式。

C#
public virtual System.Drawing.ContentAlignment TextAlign { get; set; }

属性值

ContentAlignment

ContentAlignment 值之一。 默认值为 MiddleRight

例外

分配的值不是 ContentAlignment 值之一。

示例

下面的代码示例演示Image了 a ToolStripButton的 、ImageAlignDisplayStyleTextAlign属性。 此示例是类概述中提供的大型示例的 ToolStripButton 一部分。

C#
this.toolStripButton1.Image = Bitmap.FromFile("c:\\NewItem.bmp");
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText;
this.toolStripButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Text = "&New";
this.toolStripButton1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);

注解

使用 TextAlign 属性获取或设置文本对齐方式 ToolStripItem。 使用 ImageAlign 属性获取或设置图像对齐方式 ToolStripItem

适用于

产品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另请参阅