ToolStripItemImageScaling Wyliczenie

Definicja

Określa, czy rozmiar obrazu na obiekcie ToolStripItem jest automatycznie dostosowywany tak, aby mieścił się na obiekcie ToolStrip przy zachowaniu proporcji oryginalnego obrazu.

public enum class ToolStripItemImageScaling
public enum ToolStripItemImageScaling
type ToolStripItemImageScaling = 
Public Enum ToolStripItemImageScaling
Dziedziczenie
ToolStripItemImageScaling

Pola

None 0

Określa, że rozmiar obrazu na obiekcie ToolStripItem nie jest automatycznie dostosowywany tak, aby mieścił się w obiekcie ToolStrip.

SizeToFit 1

Określa, że rozmiar obrazu na obiekcie ToolStripItem jest automatycznie dostosowywany tak, aby mieścił się w obiekcie ToolStrip.

Przykłady

Poniższy przykład ustawia ToolStripItem.ImageScaling właściwość na SizeToFitwartość .

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

Uwagi

Właściwości Image, , ImageIndexImageAlign, ImageKeyi ImageScaling odnoszą się do różnych aspektów obsługi obrazów. Użyj obrazów w ToolStrip kontrolkach, ustawiając te właściwości bezpośrednio lub ustawiając właściwość tylko ImageList w czasie wykonywania.

Skalowanie obrazów jest określane przez interakcję właściwości w obiektach ToolStrip i ToolStripItemw następujący sposób:

  • ImageScalingSize to skala obrazu końcowego określona przez kombinację ustawienia obrazu ImageScaling i ustawienia kontenera AutoSize .

    • Jeśli AutoSize parametr ma wartość true (wartość domyślna) i ToolStripItemImageScaling ma SizeToFitwartość , nie ma skalowania obrazu, a ToolStrip rozmiar to największy element lub zalecany minimalny rozmiar.

    • Jeśli AutoSize parametr ma false wartość i ToolStripItemImageScaling jest None, ani obraz, ani ToolStrip skalowanie nie występuje.

Aby kontrolować rozmiar obrazu, użyj ImageScalingSize właściwości .

Dotyczy