語言

ToolStripItemImageScaling 列舉

定義

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

public enum class ToolStripItemImageScaling
public enum ToolStripItemImageScaling
type ToolStripItemImageScaling = 
Public Enum ToolStripItemImageScaling
繼承
ToolStripItemImageScaling

欄位

名稱 值 Description
None 0

指定 a ToolStripItem 上的影像大小不會自動調整以適合 ToolStrip。

SizeToFit 1

指定影像在 a ToolStripItem 上的大小會自動調整以適合 ToolStrip。

範例

以下範例將性質 ToolStripItem.ImageScaling 設定為 SizeToFit。

ToolStripButton^ imageButton;

void InitializeImageButtonWithToolTip()
{

    // Construct the button and set the image-related properties.
    imageButton = gcnew ToolStripButton;
    imageButton->Image = 
        gcnew Bitmap(Timer::typeid,"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);
}


//   internal:
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);
}
Friend WithEvents imageButton As ToolStripButton

Private Sub InitializeImageButtonWithToolTip()

    ' Construct the button and set the image-related properties.
    imageButton = New ToolStripButton()
    imageButton.Image = New Bitmap(GetType(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)

End Sub

備註

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

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

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

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

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

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

適用於