?
Solved

Howto AddRange to ListView??

Posted on 2008-10-15
1
Medium Priority
?
1,477 Views
Last Modified: 2013-11-26
Hi,

I am trying to use Listview.AddRange in VB.NET but its expecting an array, unfortunately I don't know how many items will be in the array, so I was going to use an ArrayList... Unfortunately, you can't use this inside the AddRange.

Does anyone have a simple example of building an array and adding it using AddRange?


Thanks!
0
Comment
Question by:nickrawlins
1 Comment
 
LVL 2

Accepted Solution

by:
wmestrom earned 2000 total points
ID: 22724125
Hi,

you can use to ToArray method of a List(Of ListViewItem) instead. Hope that helps.

Greets,
Willem
        Dim listView As New System.Windows.Forms.ListView
        Dim itemList As New List(Of System.Windows.Forms.ListViewItem)
        itemList.Add(New System.Windows.Forms.ListViewItem("Item1"))
        itemList.Add(New System.Windows.Forms.ListViewItem("Item2"))
        listView.Items.AddRange(itemList.ToArray)

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question