Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Howto AddRange to ListView??

Posted on 2008-10-15
1
Medium Priority
?
1,472 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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