ToolStripItemImageScaling Enum

Definisi

Menentukan apakah ukuran gambar pada ToolStripItem secara otomatis disesuaikan agar pas pada ToolStrip sambil mempertahankan proporsi gambar asli.

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

Bidang

Nama Nilai Deskripsi
None 0

Menentukan bahwa ukuran gambar pada ToolStripItem tidak secara otomatis disesuaikan agar pas pada ToolStrip.

SizeToFit 1

Menentukan bahwa ukuran gambar pada ToolStripItem secara otomatis disesuaikan agar pas pada ToolStrip.

Contoh

Contoh berikut mengatur properti ke ToolStripItem.ImageScalingSizeToFit.

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

Keterangan

Properti Image, , ImageIndexImageAlign, ImageKey, dan ImageScaling berkaitan dengan berbagai aspek penanganan gambar. Gunakan gambar dalam ToolStrip kontrol dengan mengatur properti ini secara langsung atau dengan mengatur properti run-time-only ImageList .

Penskalaan gambar ditentukan oleh interaksi properti di dan ToolStripToolStripItem, sebagai berikut:

  • ImageScalingSize adalah skala gambar akhir seperti yang ditentukan oleh kombinasi pengaturan gambar ImageScaling dan pengaturan kontainer AutoSize .

    • Jika AutoSize adalah true (default) dan ToolStripItemImageScaling adalah SizeToFit, tidak ada penskalaan gambar yang terjadi, dan ToolStrip ukurannya adalah item terbesar, atau ukuran minimum yang ditentukan.

    • Jika AutoSize dan adalah ToolStripItemImageScalingfalseNone, tidak ada gambar maupun ToolStrip penskalakan yang terjadi.

Untuk mengontrol ukuran gambar, gunakan ImageScalingSize properti .

Berlaku untuk