Set Label's ImageList : Label « GUI « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » GUI » Label 
14.2.7.Set Label's ImageList
Set Label's ImageList
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 = to arFiles.Length - 1
      img = Image.FromFile(arFiles(i))
      imgList.Images.Add(img)
    next

    imgList.ImageSize = new Size(3232)

    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(060)
    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
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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.