Add image to Label : Label « GUI « VB.Net Tutorial






Add image to Label
imports System
imports System.Drawing
imports System.Windows.Forms

public class LabelImage: inherits Form
  public sub New()
    Size = new Size(300,250)

    dim img as Image = Image.FromFile("yourfile.jpg")
    dim lblImage as Label = new Label()
    lblImage.Parent = me
    lblImage.Location = new Point(0, 0)
    lblImage.Image = img
    lblImage.Anchor = AnchorStyles.Top or AnchorStyles.Right
    lblImage.Size = new Size(img.Width, img.Height)
  end sub

  public shared sub Main() 
    Application.Run(new LabelImage())
  end sub

end class








14.2.Label
14.2.1.Label TextAlignLabel TextAlign
14.2.2.Change Label text and width in Button actionChange Label text and width in Button action
14.2.3.Change Label fontChange Label font
14.2.4.Use Color dialog to set the Label foreground colorUse Color dialog to set the Label foreground color
14.2.5.Label mouse click eventLabel mouse click event
14.2.6.Add image to LabelAdd image to Label
14.2.7.Set Label's ImageListSet Label's ImageList
14.2.8.Multiline LabelMultiline Label