Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ruponentModel
Imports System.Drawing.Drawing2D
Imports System.IO
Public Class MainClass
Shared Sub Main()
Dim form1 As Form = New Form1
Application.Run(form1)
End Sub
End Class
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents cmdFillImageList As System.Windows.Forms.Button
Friend WithEvents cmdDrawImageList As System.Windows.Forms.Button
"Required by the Windows Form Designer
Private components As System.ruponentModel.Container
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.cmdDrawImageList = New System.Windows.Forms.Button()
Me.cmdFillImageList = New System.Windows.Forms.Button()
Me.SuspendLayout()
"
"cmdDrawImageList
"
Me.cmdDrawImageList.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.cmdDrawImageList.Location = New System.Drawing.Point(176, 164)
Me.cmdDrawImageList.Name = "cmdDrawImageList"
Me.cmdDrawImageList.Size = New System.Drawing.Size(96, 24)
Me.cmdDrawImageList.TabIndex = 1
Me.cmdDrawImageList.Text = "Draw Images"
"
"cmdFillImageList
"
Me.cmdFillImageList.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.cmdFillImageList.Location = New System.Drawing.Point(40, 164)
Me.cmdFillImageList.Name = "cmdFillImageList"
Me.cmdFillImageList.Size = New System.Drawing.Size(104, 24)
Me.cmdFillImageList.TabIndex = 0
Me.cmdFillImageList.Text = "Fill ImageList"
"
"ImageListExample
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
Me.ClientSize = New System.Drawing.Size(320, 210)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdDrawImageList, Me.cmdFillImageList})
Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Name = "ImageListExample"
Me.Text = "ImageList Example"
Me.ResumeLayout(False)
End Sub
#End Region
Private IconImages As New System.Windows.Forms.ImageList()
Private Sub cmdDrawImageList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDrawImageList.Click
Dim g As Graphics = Me.CreateGraphics
Dim i As Integer
For i = 0 To IconImages.Images.Count - 1
IconImages.Draw(g, 30 + i * 30, 30, i)
Next
g.Dispose()
End Sub
Private Sub cmdFillImageList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFillImageList.Click
IconImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
IconImages.ImageSize = New System.Drawing.Size(16, 16)
Dim IconFile As String, IconFiles As String()
IconFiles = Directory.GetFiles("", "*.ico")
For Each IconFile In IconFiles
Dim NewIcon As New Icon(IconFile)
IconImages.Images.Add(NewIcon)
Next
End Sub
End Class