ButtonBase.TextAlign Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the alignment of the text on the button control.
public:
virtual property System::Drawing::ContentAlignment TextAlign { System::Drawing::ContentAlignment get(); void set(System::Drawing::ContentAlignment value); };
public virtual System.Drawing.ContentAlignment TextAlign { get; set; }
member this.TextAlign : System.Drawing.ContentAlignment with get, set
Public Overridable Property TextAlign As ContentAlignment
Property Value
One of the ContentAlignment values. The default is MiddleCenter
.
Exceptions
The value assigned is not one of the ContentAlignment values.
Examples
The following code example uses the derived class, Button and sets some of its common properties. The result will be a flat button with text on the left and an image on the right. This code requires that you have a bitmap image named MyBitMap.bmp
stored in the C:\Graphics
directory, and that a reference to the System.Drawing namespace is included.
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 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
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기