Control.BackgroundImage Özellik

Tanım

Denetimde görüntülenen arka plan görüntüsünü alır veya ayarlar.

C#
public virtual System.Drawing.Image BackgroundImage { get; set; }
C#
public virtual System.Drawing.Image? BackgroundImage { get; set; }

Özellik Değeri

Image Denetimin arka planında görüntülenecek görüntüyü temsil eden bir.

Örnekler

Aşağıdaki kod örneği forma bir Button ekler ve bazı ortak özelliklerini ayarlar. Örnek düğmeyi formun sağ alt köşesine sabitler, böylece form yeniden boyutlandırılırken göreli konumunu korur. Ardından düğmesini ayarlar BackgroundImage ve düğmeyi ile aynı boyuta Imageyeniden boyutlandırılır. Örnek daha sonra öğesini TabStoptrue olarak ayarlar ve özelliğini ayarlar TabIndex . Son olarak, düğmenin olayını işlemek Click için bir olay işleyicisi ekler. Bu örnekte adlı imageList1bir ImageList olması gerekir.

C#
// Add a button to a form and set some of its common properties.
private void AddMyButton()
{
   // Create a button and add it to the form.
   Button button1 = new Button();

   // Anchor the button to the bottom right corner of the form
   button1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);

   // Assign a background image.
   button1.BackgroundImage = imageList1.Images[0];

   // Specify the layout style of the background image. Tile is the default.
   button1.BackgroundImageLayout = ImageLayout.Center;
   
   // Make the button the same size as the image.
   button1.Size = button1.BackgroundImage.Size;

   // Set the button's TabIndex and TabStop properties.
   button1.TabIndex = 1;
   button1.TabStop = true;

   // Add a delegate to handle the Click event.
   button1.Click += new System.EventHandler(this.button1_Click);

   // Add the button to the form.
   this.Controls.Add(button1);
}

Açıklamalar

  • Bir denetime BackgroundImage grafik görüntüsü yerleştirmek için özelliğini kullanın.

Not

Saydam veya saydam renklere sahip görüntüler, arka plan görüntüleri olarak Windows Forms denetimler tarafından desteklenmez.

Bu özellik, özelliği trueolan RightToLeftLayout alt denetimlerde desteklenmez.

Devralanlara Notlar

Türetilmiş bir sınıfta özelliğini geçersiz kıldığınızda BackgroundImage temel uygulamanın kapsamını genişletmek için temel sınıfın BackgroundImage özelliğini kullanın. Aksi takdirde, tüm uygulamayı sağlamanız gerekir. Özelliğin get hem hem set de erişimcilerini BackgroundImage geçersiz kılmanız gerekmez; gerekirse yalnızca birini geçersiz kılabilirsiniz.

Şunlara uygulanır

Ürün Sürümler
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Ayrıca bkz.