Gets or sets the image that is displayed on a button control.
[Visual Basic] Public Property Image As Image [C#] public Image Image {get; set;} [C++] public: __property Image* get_Image(); public: __property void set_Image(Image*); [JScript] public function get Image() : Image; public function set Image(Image);
The Image displayed on the button control. The default value is a null reference (in Visual Basic Nothing).
When the Image property is set the ImageList property will be set to a null reference (Nothing) and the ImageIndex property will be set to its default,-1.
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 | ImageList