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

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ButtonBase.TextAlign プロパティの意味・解説 

ButtonBase.TextAlign プロパティ

ボタン コントロールのテキストの配置を取得または設定します。

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

<LocalizableAttribute(True)> _
Public Overridable Property
 TextAlign As ContentAlignment
Dim instance As ButtonBase
Dim value As ContentAlignment

value = instance.TextAlign

instance.TextAlign = value
[LocalizableAttribute(true)] 
public virtual ContentAlignment TextAlign { get;
 set; }
[LocalizableAttribute(true)] 
public:
virtual property ContentAlignment TextAlign {
    ContentAlignment get ();
    void set (ContentAlignment value);
}
/** @property */
public ContentAlignment get_TextAlign ()

/** @property */
public void set_TextAlign (ContentAlignment
 value)
public function get TextAlign
 () : ContentAlignment

public function set TextAlign
 (value : ContentAlignment)

プロパティ値
ContentAlignment 値の 1 つ。既定値は MiddleCenter です。

例外例外
例外の種類条件

InvalidEnumArgumentException

代入された値が、ContentAlignment 値ではありません。

使用例使用例

派生クラス Button を使用して、その共通プロパティの一部を設定するコード例を次に示します。結果として、テキストを左側、イメージを右側に含むフラットなボタンが表示されます。このコードでは、C:\Graphics ディレクトリに MyBitMap.bmp という名前のビットマップ イメージが格納されており、System.Drawing 名前空間への参照がコードに含まれている必要があります。

Private Sub SetMyButtonProperties()
    ' Assign an image to the button.
    button1.Image = Image.FromFile("C:\Graphics\MyBitmap.bmp")
    ' Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight
    button1.TextAlign = ContentAlignment.MiddleLeft
    ' Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat
End Sub 'SetMyButtonProperties
private void SetMyButtonProperties()
 {
    // Assign an image to the button.
    button1.Image = Image.FromFile("C:\\Graphics\\MyBitmap.bmp");
    // Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight;    
    button1.TextAlign = ContentAlignment.MiddleLeft;
    // Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat;
 }
 
private:
   void SetMyButtonProperties()
   {
      // Assign an image to the button.
      button1->Image = Image::FromFile( "C:\\Graphics\\MyBitmap.bmp"
 );
      // Align the image and text on the button.
      button1->ImageAlign = ContentAlignment::MiddleRight;
      button1->TextAlign = ContentAlignment::MiddleLeft;
      // Give the button a flat appearance.
      button1->FlatStyle = FlatStyle::Flat;
   }
private void SetMyButtonProperties()
{
    // Assign an image to the button.
    button1.set_Image(Image.FromFile("C:\\Graphics\\MyBitmap.bmp"));

    // Align the image and text on the button.
    button1.set_ImageAlign(ContentAlignment.MiddleRight);
    button1.set_TextAlign(ContentAlignment.MiddleLeft);

    // Give the button a flat appearance.
    button1.set_FlatStyle(FlatStyle.Flat);
} //SetMyButtonProperties
private function SetMyButtonProperties()
 {
    // Assign an image to the button.
    button1.Image = Image.FromFile("C:\\Graphics\\MyBitmap.bmp");
    // Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight;    
    button1.TextAlign = ContentAlignment.MiddleLeft;
    // Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat;
 }
 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「ButtonBase.TextAlign プロパティ」の関連用語

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

   

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



ButtonBase.TextAlign プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS