Solved

Howto AddRange to ListView??

Posted on 2008-10-15
1
1,441 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 500 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now