Label.AutoSize 속성

정의

전체 내용이 표시되도록 컨트롤의 크기를 자동으로 조정할지를 나타내는 값을 가져오거나 설정합니다.

public:
 virtual property bool AutoSize { bool get(); void set(bool value); };
public virtual bool AutoSize { get; set; }
[System.ComponentModel.Browsable(true)]
public override bool AutoSize { get; set; }
member this.AutoSize : bool with get, set
[<System.ComponentModel.Browsable(true)>]
member this.AutoSize : bool with get, set
Public Overridable Property AutoSize As Boolean
Public Overrides Property AutoSize As Boolean

속성 값

Boolean

컨트롤이 해당 내용에 맞도록 너비를 조정하면 true이고 조정하지 않으면 false입니다. 디자이너를 사용할 때 폼에 추가했습니다. 기본값은 true입니다. 코드에서 인스턴스화할 때 기본값은 false입니다.

특성

예제

다음 코드 예제는 AutoSize 속성입니다. 이 예제를 실행하려면 폼에 다음 코드를 붙여넣고 폼의 생성자 또는 Load 메서드에서 메서드를 호출 InitializeLabel 합니다.

   // Declare a label.
internal:
   System::Windows::Forms::Label ^ Label1;

private:

   // Initialize the label.
   void InitializeLabel()
   {
      this->Label1 = gcnew Label;
      this->Label1->Location = System::Drawing::Point( 10, 10 );
      this->Label1->Name = "Label1";
      this->Label1->TabIndex = 0;
      
      // Set the label to a small size, but set the AutoSize property 
      // to true. The label will adjust its length so all the text
      // is visible, however if the label is wider than the form,
      // the entire label will not be visible.
      this->Label1->Size = System::Drawing::Size( 10, 10 );
      this->Controls->Add( this->Label1 );
      this->Label1->AutoSize = true;
      this->Label1->Text = "The text in this label is longer"
      " than the set size.";
   }
// Declare a label.
internal System.Windows.Forms.Label Label1;

// Initialize the label.
private void InitializeLabel()
{
    this.Label1 = new Label();
    this.Label1.Location = new System.Drawing.Point(10, 10);
    this.Label1.Name = "Label1";
    this.Label1.TabIndex = 0;

    // Set the label to a small size, but set the AutoSize property 
    // to true. The label will adjust its length so all the text
    // is visible, however if the label is wider than the form,
    // the entire label will not be visible.
    this.Label1.Size = new System.Drawing.Size(10, 10);
    this.Controls.Add(this.Label1);
    this.Label1.AutoSize = true;
    this.Label1.Text = "The text in this label is longer" +  
        " than the set size.";
}
' Declare a label.
Friend WithEvents Label1 As System.Windows.Forms.Label

' Initialize the label.
Private Sub InitializeLabel()
    Me.Label1 = New Label
    Me.Label1.Location = New System.Drawing.Point(10, 10)
    Me.Label1.Name = "Label1"
    Me.Label1.TabIndex = 0

    ' Set the label to a small size, but set the AutoSize property 
    ' to true. The label will adjust its length so all the text
    ' is visible, however if the label is wider than the form,
    ' the entire label will not be visible.
    Me.Label1.Size = New System.Drawing.Size(10, 10)
    Me.Controls.Add(Me.Label1)
    Me.Label1.AutoSize = True
    Me.Label1.Text = "The text in this label is longer than the set size."

End Sub

설명

이 속성이 설정 true되면 너비를 Label 조정하여 전체 내용을 표시합니다. 이 속성은 대개로 설정 됩니다 true 사용 하는 경우는 Label 다양 한 길이의 애플리케이션 프로세스의 상태와 같은 텍스트를 표시 하는 컨트롤입니다. 애플리케이션은 다양 한 언어로 텍스트를 표시 하 고 텍스트의 크기를 늘릴 수 있습니다 또는 Windows의 언어 설정에 따라 감소 하는 경우에이 속성을 사용할 수 있습니다.

중요

글꼴이 높이 Label AutoEllipsis true보다 크고 높이인 경우 텍스트를 그릴 수 있도록 false 설정 AutoSize 해야 합니다.

적용 대상

추가 정보