ToolStripItem.TextAlign 屬性

定義

取得或設定 ToolStripLabel 上文字的對齊方式。

public:
 virtual property System::Drawing::ContentAlignment TextAlign { System::Drawing::ContentAlignment get(); void set(System::Drawing::ContentAlignment value); };
public virtual System.Drawing.ContentAlignment TextAlign { get; set; }
member this.TextAlign : System.Drawing.ContentAlignment with get, set
Public Overridable Property TextAlign As ContentAlignment

屬性值

ContentAlignment

其中一個 ContentAlignment 值。 預設為 MiddleRight

例外狀況

所指派的值不是其中一個 ContentAlignment 值。

範例

下列程式碼範例示範 的 ImageImageAlign DisplayStyle 、 和 TextAlign 屬性 ToolStripButton 。 此範例是類別概觀中較大範例的 ToolStripButton 一部分。

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);
Me.toolStripButton1.Image = Bitmap.FromFile("c:\NewItem.bmp")
Me.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText
Me.toolStripButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.toolStripButton1.Name = "toolStripButton1"
Me.toolStripButton1.Text = "&New"
Me.toolStripButton1.TextAlign = System.Drawing.ContentAlignment.MiddleRight

備註

TextAlign使用 屬性取得或設定 上的 ToolStripItem 文字對齊方式。 ImageAlign使用 屬性取得或設定 上的 ToolStripItem 影像對齊方式。

適用於

另請參閱