Add image to Label and set ImageAlign to MiddleRight : Label « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » GUI Windows Form » LabelScreenshots 
Add image to Label and set ImageAlign to MiddleRight
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(209);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(10577);
        this.label1.TabIndex = 0;
        this.label1.Text = "label1";

        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(299271);

        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
1.Label: Localtion, Name, Size, TabIndex, Text
2.Label grows as the inner textLabel grows as the inner text
3.Label auto resizeLabel auto resize
4.Set Label Background, foreground color and border styleSet Label Background, foreground color and border style
5.Marquee Label HostMarquee Label Host
6.Use Label and Timer to create a Clock
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.