ToolStripItem.Alignment Özellik

Tanım

Öğenin başlangıcına veya sonuna ToolStripdoğru hizalanıp hizalanmadığını belirten bir değer alır veya ayarlar.

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

Özellik Değeri

ToolStripItemAlignment

Değerlerden ToolStripItemAlignment biri. Varsayılan değer: Left.

Özel durumlar

Atanan değer değerlerden ToolStripItemAlignment biri değil.

Örnekler

Aşağıdaki kod örneğinde özelliğin nasıl ayarlanacağı gösterilmektedir Alignment . Bu kod örneği, sınıfı için ToolStripItem sağlanan daha büyük bir örneğin parçasıdır.

// 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

Açıklamalar

Yığın taşması düzenindeAlignment, bir içinde öğelerin hizalandığı ucu denetlemek veya zaten hizalanmış ToolStripoldukları ucu belirlemek için özelliğiyle ToolStripItem.RightToLeft birlikte özelliğini kullanın.

ToolStripItem.RightToLeft özelliği iseNo, olarak Left işaretlenen öğeler öğesinin ToolStrip sol tarafına hizalanır ve işaretlenen Right öğeler sağa hizalanır.

ToolStripItem.RightToLeft özelliği iseYes, olarak Left işaretlenen öğeler öğesinin ToolStrip sağ tarafına hizalanır ve işaretlenen Right öğeler sola hizalanır.

Not

Akış ve tablo düzenlerinde Alignment özelliği yoksayılır. Akış veya tablo düzeninde Dock , satır veya tablo hücresi içindeki öğeleri hizalamak için or Anchor özelliğini kullanın.

Şunlara uygulanır