Label.AutoSize プロパティとは? わかりやすく解説

Label.AutoSize プロパティ

内容をすべて表示するためにコントロールサイズ自動調整するかどうかを示す値を取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<LocalizableAttribute(True)> _
Public Overrides Property
 AutoSize As Boolean
Dim instance As Label
Dim value As Boolean

value = instance.AutoSize

instance.AutoSize = value
[LocalizableAttribute(true)] 
public override bool AutoSize { get;
 set; }
[LocalizableAttribute(true)] 
public:
virtual property bool AutoSize {
    bool get () override;
    void set (bool value)
 override;
}
/** @property */
public boolean get_AutoSize ()

/** @property */
public void set_AutoSize (boolean value)

プロパティ
表示内容合わせてコントロールの幅調整する場合trueそれ以外場合false既定値false です。

解説解説
使用例使用例

AutoSize プロパティコード例次に示します。この例を実行するには、次のコードフォーム貼り付けてフォームコンストラクタまたは Load メソッドから InitializeLabel メソッド呼び出します。

' 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
// 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.
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.
private System.Windows.Forms.Label label1;

// Initialize the label.
private void InitializeLabel()
{
    this.label1 = new Label();
    this.label1.set_Location(new System.Drawing.Point(10,
 10));
    this.label1.set_Name("label1");
    this.label1.set_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.set_Size(new System.Drawing.Size(10,
 10));
    this.get_Controls().Add(this.label1);
    this.label1.set_AutoSize(true);
    this.label1.set_Text("The text in
 this label is longer" 
        + " than the set size.");
} //InitializeLabel
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Label.AutoSize プロパティ」の関連用語

Label.AutoSize プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Label.AutoSize プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS