?
Solved

vb.net - load large txt data into listview

Posted on 2009-12-16
5
Medium Priority
?
485 Views
Last Modified: 2012-08-13
hello there,
I have this code to load data into a listview but since its about 50,000 records its taking a about 8 to 15 seconds to load..
I was wondering if there is a way to load these items faster?
Public Sub LoadNames(ByVal mPath As String, ByVal LVW As ListView)
        Dim lvi As ListViewItem, line As String
        If System.IO.File.Exists(mPath) Then
            Using sr As New System.IO.StreamReader(mPath)
                While Not sr.EndOfStream
                    line = sr.ReadLine()
                    If line.Length > 0 Then
                        lvi = LVW.Items.Add(line)
                    End If
                End While
            End Using
        End If
    End Sub

Open in new window

0
Comment
Question by:XK8ER
  • 2
  • 2
5 Comments
 
LVL 1

Author Comment

by:XK8ER
ID: 26069475
i think you are in the wrong section
0
 
LVL 27

Expert Comment

by:planocz
ID: 26077926
How large are the records per row?
Why or what are you  going to do with the records?
May be better to break down into sections.
0
 
LVL 1

Author Comment

by:XK8ER
ID: 26081544
I just want to import the records into a listview.. samples here

Daniel
Salmon
Bob
Roby
Lenny
0
 
LVL 27

Accepted Solution

by:
planocz earned 200 total points
ID: 26085985
what you have in the above code for a listview is about as good as it gets.
thats why I ask
How large are the records per row?
Why or what are you  going to do with the records?
May be better to break down into sections.

If you are just doing this for fun 8 to 15 sec. is not to bad.
If you are doing this for a real working app. then you may want to rethink about using a listview.
You must have a reason for the way you are doing this. that is not appearent in what you state above.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

839 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