語言

ToolStripItem.Image 屬性

定義

取得或設定顯示在 ToolStripItem. 上的影像。

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

屬性值

Image將被展示。

範例

以下程式碼範例展示了 Image的 ImageAlign、 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

備註

Image、ImageAlign、ImageIndex、ImageKey 及 ImageScaling 屬性與影像處理的各個層面有關。 在控制項中使用圖片 ToolStrip ,可直接設定這些屬性,或設定僅執行 ImageList 時的屬性。

影像縮放是由 ToolStrip 和 ToolStripItem 中的屬性交互決定的,如下所示:

  • ImageScalingSize 是由影像的 ImageScaling 設定和容器的 AutoSize 設定組合所決定的最終影像縮放比例。

    • 如果 AutoSize 是 true(預設值),且 ToolStripItemImageScaling 是 SizeToFit,那麼不會進行影像縮放,ToolStrip 的大小將為最大項目或是指定的最小尺寸。

    • 如果AutoSize 是false 且ToolStripItemImageScaling 是None,則不會發生影像或ToolStrip縮放。

適用於