Add image to Label and set ImageAlign to MiddleRight
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
private System.Windows.Forms.Label label1;
public Form1() {
InitializeComponent();
}
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.label1.Image = new Bitmap("winter.jpg");
this.label1.ImageAlign = System.Drawing.ContentAlignment.TopRight;
this.label1.Location = new System.Drawing.Point(20, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(105, 77);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(299, 271);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "ImagesInCommonControls";
this.Text = "ImagesInCommonControls";
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
Related examples in the same category