Solved

Howto AddRange to ListView??

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

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

Suggested Solutions

Title # Comments Views Activity
how to make search between pages 17 59
reading an excel file vb.net 2 44
Data Analysis 7 58
Easiest intro into .NET CORE? 2 31
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

737 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