467,075 Members | 1,006 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,075 developers. It's quick & easy.

Image List

Hi all
Is there any limit of images which can be added to a image list. I
have a problem with this control. I added an image list in design mode
and I am adding images using code. Then I want to use images in a
listview, and each time I am trying to call an image at index 15 or
above I have an error stating that there isn't any object at that
index. I was debbuging it and there was more there was 22 images, but
only 15 I can load.

Is there any way I can add and display more than 15 images. What is
causing that problem?

Thanks

Mar 8 '07 #1
  • viewed: 2565
Share:
3 Replies
I doubt there is a limit, but it would probably help us if you posted your
code
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

<gr************@googlemail.comwrote in message
news:11**********************@c51g2000cwc.googlegr oups.com...
Hi all
Is there any limit of images which can be added to a image list. I
have a problem with this control. I added an image list in design mode
and I am adding images using code. Then I want to use images in a
listview, and each time I am trying to call an image at index 15 or
above I have an error stating that there isn't any object at that
index. I was debbuging it and there was more there was 22 images, but
only 15 I can load.

Is there any way I can add and display more than 15 images. What is
causing that problem?

Thanks

Mar 8 '07 #2
You can have more than 15 images in an imagelist control.

Not sure of the limitations but way more than 15 I think I had 200 or so
(they were only littel 32x32 icons though)

Mike.
<gr************@googlemail.comwrote in message
news:11**********************@c51g2000cwc.googlegr oups.com...
Hi all
Is there any limit of images which can be added to a image list. I
have a problem with this control. I added an image list in design mode
and I am adding images using code. Then I want to use images in a
listview, and each time I am trying to call an image at index 15 or
above I have an error stating that there isn't any object at that
index. I was debbuging it and there was more there was 22 images, but
only 15 I can load.

Is there any way I can add and display more than 15 images. What is
causing that problem?

Thanks

Mar 8 '07 #3
On 8 Mar, 23:26, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I doubt there is a limit, but it would probably help us if you posted your
code
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/

<grzegorz.ga...@googlemail.comwrote in message

news:11**********************@c51g2000cwc.googlegr oups.com...
Hi all
Is there any limit of images which can be added to a image list. I
have a problem with this control. I added an image list in design mode
and I am adding images using code. Then I want to use images in a
listview, and each time I am trying to call an image at index 15 or
above I have an error stating that there isn't any object at that
index. I was debbuging it and there was more there was 22 images, but
only 15 I can load.
Is there any way I can add and display more than 15 images. What is
causing that problem?
Thanks
Ok I am posting some code

Dim imgFlag As Image

sCountry = LookUpDetails(row("ip").ToString)
newRow = dsReport.Tables("Countries").Rows.Find(sCountry)
If newRow Is Nothing Then
newRow = dsReport.Tables("Countries").NewRow
newRow("CountryName") = sCountry
newRow("CountryHits") = CInt(row("hits").ToString)
newRow("CountryVisitors") = 1
newRow("CountryCode") =
LookUpCountryCode(row("ip").ToString)
Try
'Adding image to ImageList
imgFlag = Image.FromFile(sImagePath &
newRow("CountryCode").ToString.ToLower & ".gif")

ilCountries.Images.Add(newRow("CountryCode").ToStr ing, imgFlag)

Catch ex As IO.FileNotFoundException
EventLog.WriteEntry("LogAnalyst", "Image file was
not found. Path for desired image: " & sImagePath &
newRow("CountryCode").ToString.ToLower & ".gif",
EventLogEntryType.Error, 100)
End Try

dsReport.Tables("Countries").Rows.Add(newRow)
Else
newRow("CountryHits") += CInt(row("hits").ToString)
newRow("CountryVisitors") += 1
End If

And another bit where error appears

Dim item As ListViewItem

If rows.Length 0 Then
StatAnalyst.ListView2.StateImageList =
StatAnalyst.ilCountries
For Each row In rows
item = New
ListViewItem(row("CountryName").ToString)
Try
item.StateImageIndex =
StatAnalyst.ilCountries.Images.IndexOfKey(row("Cou ntryCode").ToString)
Catch
End Try
item.SubItems.Add(row("CountryHits").ToString)
item.SubItems.Add(row("CountryVisitors").ToString)
StatAnalyst.ListView2.Items.Add(item)
Next
End If

Error message from exception:
System.ArgumentOutOfRangeException: InvalidArgument=Value of '21' is
not valid for 'StateImageIndex'.
Parameter name: StateImageIndex
at System.Windows.Forms.ListViewItem.set_StateImageIn dex(Int32
value)
at Stat_Analyzer.Reports.CreateCountries() in Path\Stat Analyzer
\Stat Analyzer\Reports.vb:line 112

At the moment when error appears there are 22 images in ListView. On
ListView only 15 are displayed properly, only 15 appeared.

I have the same problem with another ListView in which I have 16
items. That list was created using design mode, but when I was trying
to add image from index 15 I got the same error as above.

Mar 9 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dave | last post: by
1 post views Thread by Desigan Chinniah | last post: by
6 posts views Thread by Haines Brown | last post: by
1 post views Thread by Ronny | last post: by
4 posts views Thread by Gabriella | last post: by
5 posts views Thread by Roy Smith | last post: by
reply views Thread by Lou O | last post: by
1 post views Thread by Angelo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.