Label.ImageIndex : Label « System.Windows.Forms « VB.Net by API






Label.ImageIndex

  

imports System
imports System.Drawing
imports System.Windows.Forms

public class ImageLists : inherits Form

  dim imgList as ImageList = new ImageList()
    dim lbl as Label 
    dim lnk as LinkLabel
    dim btn as Button
    dim nmbrUpDown as NumericUpDown

  public sub New()
       Size = new Size(300,300)

    dim img as Image
    dim i as integer

    dim arFiles as string() = {"1.ico","2.ico","3.ico","4.ico"}

    for i = 0 to arFiles.Length - 1
      img = Image.FromFile(arFiles(i))
      imgList.Images.Add(img)
    next

    imgList.ImageSize = new Size(32, 32)

    img = Image.FromFile("5.ico")
    imgList.Images(imgList.Images.Count - 1) = img

       lbl = new Label()
       lbl.Parent = me
       lbl.Text = "Label"
       lbl.Location = new Point(0,0)
       lbl.Size = new Size (200,20)
       lbl.BorderStyle = BorderStyle.Fixed3D
    lbl.ImageList = imgList
    lbl.ImageIndex = 0
    lbl.ImageAlign = ContentAlignment.MiddleRight

    '  Create numeric updown to select the image
    nmbrUpDown = new NumericUpDown()
    nmbrUpDown.Parent = me
    nmbrUpDown.Location = new Point(0, 60)
    nmbrUpDown.Value = 0
    nmbrUpDown.Minimum = 0
    nmbrUpDown.Maximum = imgList.Images.Count - 1
    nmbrUpDown.Width = 50
    nmbrUpDown.ReadOnly = true
    AddHandler nmbrUpDown.ValueChanged,AddressOf nmbrUpDown_ValueChanged
    end sub

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

    private sub nmbrUpDown_ValueChanged(ByVal sender as object,ByVal e as EventArgs)
      dim n as NumericUpDown  = CType(sender, NumericUpDown)
    lbl.ImageIndex = CType(n.Value, Integer)
    end sub
end class

   
    
  








Related examples in the same category

1.Label.BorderStyle
2.Label.Click
3.Label.DataBindings.Add
4.Label.DoDragDrop
5.Label.DoubleClick
6.Label.DragDrop
7.Label.DragEnter
8.Label.Font.Size
9.Label.Font.Style
10.Label.ForeColor
11.Label.Image
12.Label.ImageAlign
13.Label.ImageList
14.Label.MouseDown
15.Label.MouseEnter
16.Label.MouseHover
17.Label.MouseLeave
18.Label.MouseMove
19.Label.MouseUp
20.Label.MouseWheel
21.Label.SetBounds
22.Label.Text
23.Label.TextAlign
24.Label.Visible