ToolStripItemImageScaling Wyliczenie

Definicja

Określa, czy rozmiar obrazu na ToolStripItem jest automatycznie dostosowywany do dopasowania do ToolStrip przy zachowaniu oryginalnych proporcji obrazu.

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

Pola

Nazwa Wartość Opis
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, ImageAlign, ImageIndex, 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 systemach 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 wartość to true (wartość domyślna) i ToolStripItemImageScaling ma SizeToFitwartość , nie ma skalowania obrazu, a ToolStrip rozmiar jest taki, jaki ma największy element lub określony minimalny rozmiar.

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

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

Dotyczy