Typecast from object[] to ListViewItem[]

  • Thread starter Thread starter Henke
  • Start date Start date
H

Henke

Hi!

I'd like to use the AddRange method on a ListView to add a unknow number of
items, so I first loop through some nested datasets and add my items to a
ArrayList. Then my idea was to use
myListView.AddRange(myArrayList.ToArray()) but that doesn't work.

I think there is a better way to do this. Can someone please help me?
Thanks!

/Henke
 
Henke said:
I'd like to use the AddRange method on a ListView to add a unknow number of
items, so I first loop through some nested datasets and add my items to a
ArrayList. Then my idea was to use
myListView.AddRange(myArrayList.ToArray()) but that doesn't work.

I think there is a better way to do this. Can someone please help me?
Thanks!

If you use myArrayList.ToArray(typeof(ListViewItem)) it will return a
ListViewItem array, but you'll still need to cast it to ListViewItem[]
because the signature will only say object[].
 
Back
Top