ButtonBase.ImageAlign 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 image on the button control.
public:
property System::Drawing::ContentAlignment ImageAlign { System::Drawing::ContentAlignment get(); void set(System::Drawing::ContentAlignment value); };
public System.Drawing.ContentAlignment ImageAlign { get; set; }
member this.ImageAlign : System.Drawing.ContentAlignment with get, set
Public Property ImageAlign As ContentAlignment
Property Value
One of the ContentAlignment values. The default value 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
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈