Hi,
I have an ImageList that throws an exception when it's initialized.
I put an imagelist on form1, and populated it with 3 images. The "Images Collectionj Editor" shows they are given index numbers 0, 1 and 2.
The ImageList1-control is the only control on form1 so far. When I run this, I get:
InnerException: System.IndexOutOfRangeException
The exception is thrown in the form1.designer.vb code at the following line:
Me.ImageList1.Images.SetKeyName(0, "Disk.jpg")
How can index number 0 be invalid? (Out of range exception).
Any solution for this?
The form1.designer.vb code reads :
I have an ImageList that throws an exception when it's initialized.
I put an imagelist on form1, and populated it with 3 images. The "Images Collectionj Editor" shows they are given index numbers 0, 1 and 2.
The ImageList1-control is the only control on form1 so far. When I run this, I get:
InnerException: System.IndexOutOfRangeException
The exception is thrown in the form1.designer.vb code at the following line:
Me.ImageList1.Images.SetKeyName(0, "Disk.jpg")
How can index number 0 be invalid? (Out of range exception).
Any solution for this?
The form1.designer.vb code reads :
Code:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'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.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.SuspendLayout()
'
'ImageList1
'
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
Me.ImageList1.Images.SetKeyName(0, "Disk.jpg") ' Exception thrown here
Me.ImageList1.Images.SetKeyName(1, "Folder.jpg")
Me.ImageList1.Images.SetKeyName(2, "File.jpg")
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(644, 374)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
End Class