ToolStripItemImageScaling 列舉

定義

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

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

欄位

None 0

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

SizeToFit 1

指定 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

備註

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

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

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

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

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

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

適用於