ToolStripItem.DisplayStyle ToolStripItem.DisplayStyle ToolStripItem.DisplayStyle ToolStripItem.DisplayStyle Property

定义

获取或设置是否在 ToolStripItem 上显示文本和图像。Gets or sets whether text and images are displayed on a ToolStripItem.

public:
 virtual property System::Windows::Forms::ToolStripItemDisplayStyle DisplayStyle { System::Windows::Forms::ToolStripItemDisplayStyle get(); void set(System::Windows::Forms::ToolStripItemDisplayStyle value); };
public virtual System.Windows.Forms.ToolStripItemDisplayStyle DisplayStyle { get; set; }
member this.DisplayStyle : System.Windows.Forms.ToolStripItemDisplayStyle with get, set
Public Overridable Property DisplayStyle As ToolStripItemDisplayStyle

属性值

示例

下面的代码示例演示Image了的ImageAlign DisplayStyle 、、和TextAlign属性。 ToolStripButtonThe following code example demonstrates the Image, ImageAlign, DisplayStyle , and TextAlign properties for a ToolStripButton. 此示例是ToolStripButton类概述中提供的一个更大示例的一部分。This example is part of a larger example available in the ToolStripButton class overview.

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

注解

用于DisplayStyle设置项的文本和图像属性的值, 同时仅显示所需内容。Use DisplayStyle to set the values of an item's Text and Image properties while displaying only what you want. 这通常用于在不同的上下文中显示相同项时仅更改显示样式。This is typically used to change only the display style when showing the same item in a different context.

适用于