ToolStripItemImageScaling Énumération

Définition

Spécifie si la taille d'une image sur un ToolStripItem s'ajuste automatiquement sur un ToolStrip en conservant les proportions d'image d'origine.

public enum class ToolStripItemImageScaling
public enum ToolStripItemImageScaling
type ToolStripItemImageScaling = 
Public Enum ToolStripItemImageScaling
Héritage
ToolStripItemImageScaling

Champs

None 0

Spécifie que la taille de l'image sur un ToolStripItem ne s'ajuste pas automatiquement sur un ToolStrip.

SizeToFit 1

Spécifie que la taille de l'image sur un ToolStripItem s'ajuste automatiquement sur un ToolStrip.

Exemples

L’exemple suivant définit la ToolStripItem.ImageScaling propriété sur 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

Remarques

Les Imagepropriétés , , et ImageKeyImageAlignImageIndexImageScaling les propriétés se rapportent à différents aspects de la gestion des images. Utilisez des images dans des contrôles en ToolStrip définissant ces propriétés directement ou en définissant la propriété run-time uniquement ImageList .

La mise à l’échelle de l’image est déterminée par l’interaction des propriétés dans les deux ToolStrip et ToolStripItem, comme suit :

  • ImageScalingSize est l’échelle de l’image finale, déterminée par la combinaison du paramètre de ImageScaling l’image et du paramètre du AutoSize conteneur.

    • Si AutoSize elle est true (valeur par défaut) et ToolStripItemImageScaling SizeToFitqu’aucune mise à l’échelle d’image ne se produit, et la ToolStrip taille est celle du plus grand élément ou d’une taille minimale prescrite.

    • Si AutoSize c’est et ToolStripItemImageScaling est false None, ni l’image ni ToolStrip la mise à l’échelle ne se produisent.

Pour contrôler la taille de l’image, utilisez la ImageScalingSize propriété.

S’applique à