imports System
imports System.Drawing
imports System.Windows.Forms
public class LinkLabelImageList : 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
lnk = new LinkLabel()
lnk.Parent = me
lnk.Text = "LinkLabel"
lnk.Size = new Size(200,20)
lnk.Location = new Point(0, 0)
lnk.ImageList = imgList
lnk.ImageIndex = 0
lnk.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 LinkLabelImageList())
end sub
private sub nmbrUpDown_ValueChanged(ByVal sender as object,ByVal e as EventArgs)
dim n as NumericUpDown = CType(sender, NumericUpDown)
lnk.ImageIndex = CType(n.Value, Integer)
end sub
end class
|