Gets or sets the alignment of the image on the button control.
[Visual Basic] Public Property ImageAlign As ContentAlignment [C#] public ContentAlignment ImageAlign {get; set;} [C++] public: __property ContentAlignment get_ImageAlign(); public: __property void set_ImageAlign(ContentAlignment); [JScript] public function get ImageAlign() : ContentAlignment; public function set ImageAlign(ContentAlignment);
One of the ContentAlignment values. The default value is MiddleCenter.
Exception Type | Condition |
---|---|
InvalidEnumArgumentException | The value assigned is not one of the ContentAlignment values. |
The following 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.
[Visual Basic]
Private Sub MySub() ' Create a new resource. Dim resources As System.Resources.ResourceManager = _ New System.Resources.ResourceManager("Form1", "") ' Get an image from a resource and assign it to the button. Button1.Image = resources.GetObject("Button1.Image") ' Align the image to middle-right position on the button. Button1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight ' Make the button appear flat. Button1.FlatStyle = System.WinForms.FlatStyle.Flat ' Align the text to the middle-left position on the button. Button1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft End Sub
ButtonBase Class | ButtonBase Members | System.WinForms Namespace | TextAlign