ToolStripItem.Alignment 속성

정의

항목이 ToolStrip의 시작 부분 방향으로 맞춰지는지 아니면 끝 부분 방향으로 맞춰지는지 나타내는 값을 가져오거나 설정합니다.Gets or sets a value indicating whether the item aligns towards the beginning or end of the ToolStrip.

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

속성 값

ToolStripItemAlignment 값 중 하나입니다.One of the ToolStripItemAlignment values. 기본값은 Left입니다.The default is Left.

예외

할당된 값이 ToolStripItemAlignment 값 중 하나가 아닌 경우The value assigned is not one of the ToolStripItemAlignment values.

예제

다음 코드 예제에서는 설정 하는 방법에 설명 합니다 Alignment 속성입니다.The following code example demonstrates how to set the Alignment property. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ToolStripItem 클래스입니다.This code example is part of a larger example provided for the ToolStripItem class.

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

설명

스택 오버플로 레이아웃을 사용 하 여를 Alignment 와 함께 속성을 ToolStripItem.RightToLeft 항목 정렬 되는 끝을 제어 하는 속성을 ToolStrip, 또는는 이미 확실히 연계 되도록 끝을 확인 하.In a stack overflow layout, use the Alignment property along with the ToolStripItem.RightToLeft property to control the end to which items are aligned in a ToolStrip, or to determine the end to which they are already aligned.

경우는 ToolStripItem.RightToLeft 속성은 No로 표시 된 항목 Left 의 왼쪽에 맞춰집니다 합니다 ToolStrip 및 표시 된 항목 Right 오른쪽에 맞춰집니다.If the ToolStripItem.RightToLeft property is No, items marked as Left are aligned to the left side of the ToolStrip and items marked Right are aligned to the right.

경우는 ToolStripItem.RightToLeft 속성은 Yes로 표시 된 항목 Left 의 오른쪽에 맞춰집니다 합니다 ToolStrip 및 표시 된 항목 Right 왼쪽에 맞춰집니다.If the ToolStripItem.RightToLeft property is Yes, items marked as Left are aligned to the right side of the ToolStrip and items marked Right are aligned to the left.

참고

흐름 및 테이블 레이아웃에는 Alignment 속성은 무시 됩니다.In flow and table layouts, the Alignment property is ignored. 흐름 또는 테이블 레이아웃을 사용 합니다 Dock 또는 Anchor 행 또는 테이블 셀 내 항목 정렬 하는 속성입니다.In flow or table layout, use the Dock or Anchor property to align the items within the row or table cell.

적용 대상