On 8 Mar, 23:26, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
I doubt there is a limit, but it would probably help us if you posted your
code
--
Nathan Sokalski
njsokal...@hotm ail.comhttp://www.nathansokal ski.com/
<grzegorz.ga... @googlemail.com wrote in message
news:11******** **************@ c51g2000cwc.goo glegroups.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(r ow("ip").ToStri ng)
newRow = dsReport.Tables ("Countries").R ows.Find(sCount ry)
If newRow Is Nothing Then
newRow = dsReport.Tables ("Countries").N ewRow
newRow("Country Name") = sCountry
newRow("Country Hits") = CInt(row("hits" ).ToString)
newRow("Country Visitors") = 1
newRow("Country Code") =
LookUpCountryCo de(row("ip").To String)
Try
'Adding image to ImageList
imgFlag = Image.FromFile( sImagePath &
newRow("Country Code").ToString .ToLower & ".gif")
ilCountries.Ima ges.Add(newRow( "CountryCode"). ToString, imgFlag)
Catch ex As IO.FileNotFound Exception
EventLog.WriteE ntry("LogAnalys t", "Image file was
not found. Path for desired image: " & sImagePath &
newRow("Country Code").ToString .ToLower & ".gif",
EventLogEntryTy pe.Error, 100)
End Try
dsReport.Tables ("Countries").R ows.Add(newRow)
Else
newRow("Country Hits") += CInt(row("hits" ).ToString)
newRow("Country Visitors") += 1
End If
And another bit where error appears
Dim item As ListViewItem
If rows.Length 0 Then
StatAnalyst.Lis tView2.StateIma geList =
StatAnalyst.ilC ountries
For Each row In rows
item = New
ListViewItem(ro w("CountryName" ).ToString)
Try
item.StateImage Index =
StatAnalyst.ilC ountries.Images .IndexOfKey(row ("CountryCode") .ToString)
Catch
End Try
item.SubItems.A dd(row("Country Hits").ToString )
item.SubItems.A dd(row("Country Visitors").ToSt ring)
StatAnalyst.Lis tView2.Items.Ad d(item)
Next
End If
Error message from exception:
System.Argument OutOfRangeExcep tion: InvalidArgument =Value of '21' is
not valid for 'StateImageInde x'.
Parameter name: StateImageIndex
at System.Windows. Forms.ListViewI tem.set_StateIm ageIndex(Int32
value)
at Stat_Analyzer.R eports.CreateCo untries() in Path\Stat Analyzer
\Stat Analyzer\Report s.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.