ToolStripItem.ImageScaling Właściwość

Definicja

Pobiera lub ustawia wartość wskazującą, czy obraz na obiekcie ToolStripItem jest automatycznie zmieniany, aby zmieścił się w kontenerze.

public:
 property System::Windows::Forms::ToolStripItemImageScaling ImageScaling { System::Windows::Forms::ToolStripItemImageScaling get(); void set(System::Windows::Forms::ToolStripItemImageScaling value); };
public System.Windows.Forms.ToolStripItemImageScaling ImageScaling { get; set; }
member this.ImageScaling : System.Windows.Forms.ToolStripItemImageScaling with get, set
Public Property ImageScaling As ToolStripItemImageScaling

Wartość właściwości

Jedna z ToolStripItemImageScaling wartości. Wartość domyślna to SizeToFit.

Przykłady

W poniższym przykładzie kodu pokazano, jak ustawić Imageelement , ImageScalingi ImageTransparentColor dla elementu ToolStripItem. Ponadto pokazuje, jak ustawić i pokazać niestandardową etykietkę narzędzia dla elementu.

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, , ImageIndexi ImageKeyImageScaling 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 ToolStripItem, w następujący sposób:

Dotyczy