ToolStripItem.BackgroundImageLayout Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta il layout dell'immagine di sfondo usato per ToolStripItem.
public:
virtual property System::Windows::Forms::ImageLayout BackgroundImageLayout { System::Windows::Forms::ImageLayout get(); void set(System::Windows::Forms::ImageLayout value); };
public virtual System.Windows.Forms.ImageLayout BackgroundImageLayout { get; set; }
member this.BackgroundImageLayout : System.Windows.Forms.ImageLayout with get, set
Public Overridable Property BackgroundImageLayout As ImageLayout
Valore della proprietà
Uno dei valori di ImageLayout. Il valore predefinito è Tile.
Esempio
Nell'esempio di codice seguente viene illustrato come impostare la BackgroundImageLayout proprietà. Questo esempio di codice fa parte di un esempio più grande fornito per la ToolStripItem classe.
// This utility method creates a RolloverItem
// and adds it to a ToolStrip control.
private RolloverItem CreateRolloverItem(
ToolStrip owningToolStrip,
string txt,
Font f,
string imgKey,
TextImageRelation tir,
string backImgKey)
{
RolloverItem item = new RolloverItem();
item.Alignment = ToolStripItemAlignment.Left;
item.AllowDrop = false;
item.AutoSize = true;
item.BackgroundImage = owningToolStrip.ImageList.Images[backImgKey];
item.BackgroundImageLayout = ImageLayout.Center;
item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
item.DoubleClickEnabled = true;
item.Enabled = true;
item.Font = f;
// These assignments are equivalent. Each assigns an
// image from the owning toolstrip's image list.
item.ImageKey = imgKey;
//item.Image = owningToolStrip.ImageList.Images[infoIconKey];
//item.ImageIndex = owningToolStrip.ImageList.Images.IndexOfKey(infoIconKey);
item.ImageScaling = ToolStripItemImageScaling.None;
item.Owner = owningToolStrip;
item.Padding = new Padding(2);
item.Text = txt;
item.TextAlign = ContentAlignment.MiddleLeft;
item.TextDirection = ToolStripTextDirection.Horizontal;
item.TextImageRelation = tir;
return item;
}
' This utility method creates a RolloverItem
' and adds it to a ToolStrip control.
Private Function CreateRolloverItem( _
ByVal owningToolStrip As ToolStrip, _
ByVal txt As String, _
ByVal f As Font, _
ByVal imgKey As String, _
ByVal tir As TextImageRelation, _
ByVal backImgKey As String) As RolloverItem
Dim item As New RolloverItem()
item.Alignment = ToolStripItemAlignment.Left
item.AllowDrop = False
item.AutoSize = True
item.BackgroundImage = owningToolStrip.ImageList.Images(backImgKey)
item.BackgroundImageLayout = ImageLayout.Center
item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
item.DoubleClickEnabled = True
item.Enabled = True
item.Font = f
' These assignments are equivalent. Each assigns an
' image from the owning toolstrip's image list.
item.ImageKey = imgKey
'item.Image = owningToolStrip.ImageList.Images[infoIconKey];
'item.ImageIndex = owningToolStrip.ImageList.Images.IndexOfKey(infoIconKey);
item.ImageScaling = ToolStripItemImageScaling.None
item.Owner = owningToolStrip
item.Padding = New Padding(2)
item.Text = txt
item.TextAlign = ContentAlignment.MiddleLeft
item.TextDirection = ToolStripTextDirection.Horizontal
item.TextImageRelation = tir
Return item
End Function