mrdutchie Posted February 11, 2004 Posted February 11, 2004 Ok, I have a testfile with 40.000 lines I want to add all of these in a control. I tried Listview and it's very slow.. takes about 50 seconds to load I did use the event listview1.beginupdate and .endupdate so that speeds it up a little bit to 14 seconds , but still to slow.. Here is the source, and I hope someone can help me.. cause I see the newsreaders doing it within 1-2 seconds Dim s As Array Dim w As String Dim f As String = "C:\newsgroups.txt" Dim stream_reader As New IO.StreamReader(f) Dim he As Long Dim tmpImportProgress As Double Dim splitlist(2) As String Dim aas As String Dim z As Long Dim zz As Long z = GetTotalRows() he = z z = z - 1 s = (Split(stream_reader.ReadToEnd, vbCrLf)) stream_reader.Close() Dim c1, c2, c3 As String Dim a() As String = s(0).Split(Chr(10)) ListView1.BeginUpdate() Application.DoEvents() For x = 1 To a.Length - 2 splitlist = a(x).Split("<PKA>") c1 = splitlist(0) c2 = Mid(splitlist(1), 5, Len(splitlist(1)) - 4) c3 = Mid(splitlist(2), 5, Len(splitlist(2)) - 4) If x > 20 Then Application.DoEvents() Dim listItem1 As New ListViewItem(splitlist(0)) listItem1.SubItems.Add(c3) listItem1.SubItems.Add(c2) listItem1.SubItems.Add(c2 - c3) fakeListView.Items.Add(listItem1) ListView1.Items.Add(listItem1) tmpImportProgress += (100 / he) clsImportProgress = CInt(tmpImportProgress) RaiseEvent ImportProgress() Next Application.DoEvents() For zz = 0 To he - 1 '9 Dim listItem As New ListViewItem(fakeListView.Items(zz).SubItems(0).Text) listItem.SubItems.Add(fakeListView.Items(zz).SubItems(1).Text) listItem.SubItems.Add(fakeListView.Items(zz).SubItems(2).Text) listItem.SubItems.Add(fakeListView.Items(zz).SubItems(2).Text - fakeListView.Items(zz).SubItems(1).Text) ListView1.Items.Add(listItem) Next ListView1.EndUpdate() and here is a part from the newsgroups.txt basicly <PKA> is for seperating to different columns. So Newsgroup Endnumber Startnumber 24hoursupport.helpdesk<PKA>922050<PKA>739010 3b<PKA>5174<PKA>4224 3b.config<PKA>29105<PKA>27724 3b.misc<PKA>28002<PKA>26610 3b.tech<PKA>12728<PKA>11546 3b.test<PKA>95298<PKA>88012 Thanks so much Quote
*Gurus* divil Posted February 12, 2004 *Gurus* Posted February 12, 2004 Try using AddRange instead of Add, to add them all at once. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
mrdutchie Posted February 13, 2004 Author Posted February 13, 2004 Hmm... can't figure out the addrange method.. Looked at some examples, but still clueless Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.