閱讀英文

共用方式為


ToolStripItemImageScaling 列舉

定義

指定 ToolStripItem 上的影像大小是否會自動調整,以便容納在 ToolStrip 上,同時保留原始的影像比例。

C#
public enum ToolStripItemImageScaling
繼承
ToolStripItemImageScaling

欄位

名稱 Description
None 0

指定 ToolStripItem 上的影像大小不會自動調整,以便容納在 ToolStrip 上。

SizeToFit 1

指定 ToolStripItem 上的影像大小會自動調整,以便容納在 ToolStrip 上。

範例

下列範例會將 ToolStripItem.ImageScaling 屬性設定為 SizeToFit

C#
internal ToolStripButton imageButton;

private void InitializeImageButtonWithToolTip()
{

    // Construct the button and set the image-related properties.
    imageButton = new ToolStripButton();
    imageButton.Image = new Bitmap(typeof(Timer), "Timer.bmp");
    imageButton.ImageScaling = ToolStripItemImageScaling.SizeToFit;

    // Set the background color of the image to be transparent.
    imageButton.ImageTransparentColor = Color.FromArgb(0, 255, 0);

    // Show ToolTip text, set custom ToolTip text, and turn
    // off the automatic ToolTips.
    toolStrip1.ShowItemToolTips = true;
    imageButton.ToolTipText = "Click for the current time";
    imageButton.AutoToolTip = false;

    // Add the button to the ToolStrip.
    toolStrip1.Items.Add(imageButton);
}

備註

ImageImageAlignImageIndexImageKeyImageScaling 屬性與影像處理的各種層面有關。 直接設定這些屬性,或設定僅限 ImageList 執行時間屬性,以在控制項中使用 ToolStrip 影像。

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

  • ImageScalingSize 是最終映射的大小,取決於映射 ImageScaling 設定和容器設定 AutoSize 的組合。

    • 如果 AutoSize (true 預設) 且 ToolStripItemImageScalingSizeToFit ,則不會進行影像縮放,而且 ToolStrip 大小是最大專案的大小,或指定的最小大小。

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

若要控制影像大小,請使用 ImageScalingSize 屬性。

適用於

產品 版本
.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, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10