|
-
Nov 10th, 2012, 06:33 PM
#1
Thread Starter
Addicted Member
Thousands of Rows in a Listbox- Visual Basic 2010
Hey everyone..I hope there are some VB experts around that may know the best way to handle thousands of rows in a listbox?
I'm using Visual Basic Express 2010 and am trying to download a zip file, unzip it, and load the text file into a listbox or textbox. I have the file downloaded and unzipped properly but when trying to load this many records the program takes forever.
I was reading that a JET database may do what I'm looking for but I'm curious if anyone has experience with another method? The idea is that this list will load (about 60-100K) records and then people will be able to filter the list. I need a good way to get this to load quickly and be able to filter quickly..
Any suggestions would be appreciated!
-
Nov 10th, 2012, 10:38 PM
#2
Re: Thousands of Rows in a Listbox- Visual Basic 2010
A ListBox simply cannot handle that much data in a quick manner. It isn't very practical anyway. Do you think anyone will actually want to see every single one ? My advice is to only add filtered items and not the all the items.
-
Nov 11th, 2012, 01:42 AM
#3
Junior Member
Re: Thousands of Rows in a Listbox- Visual Basic 2010
 Originally Posted by Niya
A ListBox simply cannot handle that much data in a quick manner. It isn't very practical anyway. Do you think anyone will actually want to see every single one ? My advice is to only add filtered items and not the all the items.
I would have to agree with you on this, there seems to be no point in displaying all entries if they are going to get filtered as Niya said just display the filtered results.
-
Nov 11th, 2012, 01:53 AM
#4
Lively Member
Re: Thousands of Rows in a Listbox- Visual Basic 2010
Hi there, Play with this code,
PHP Code:
If File.Exists(Application.StartupPath & "\List.txt") Then
ListBox1.Items.Clear()
Dim a As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\List.txt")
Dim Arry() As String = {vbNewLine}
Dim b As String() = a.Split(vbNewLine)
ListBox1.Items.AddRange(b)
Else
MsgBox("File List.txt not found", MsgBoxStyle.Information)
End If
-
Nov 11th, 2012, 12:50 PM
#5
Re: Thousands of Rows in a Listbox- Visual Basic 2010
 Originally Posted by hackerspk
Hi there, Play with this code,
PHP Code:
If File.Exists(Application.StartupPath & "\List.txt") Then
ListBox1.Items.Clear()
Dim a As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\List.txt")
Dim Arry() As String = {vbNewLine}
Dim b As String() = a.Split(vbNewLine)
ListBox1.Items.AddRange(b)
Else
MsgBox("File List.txt not found", MsgBoxStyle.Information)
End If
Er, yeah. Don't!
If you're going down this path at all I would read your file into a list rather than the listbox. This has not only the advantage of being manipulated in memory but also exposes the FindAll method which will allow you to significantly speed up searches. Whether a database would be advantageous depends somewhat on the nature of the records. Do you have a sample of the file we could see?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Nov 13th, 2012, 07:57 AM
#6
Lively Member
Re: Thousands of Rows in a Listbox- Visual Basic 2010
 Originally Posted by dunfiddlin
Er, yeah. Don't!
If you're going down this path at all I would read your file into a list rather than the listbox. This has not only the advantage of being manipulated in memory but also exposes the FindAll method which will allow you to significantly speed up searches. Whether a database would be advantageous depends somewhat on the nature of the records. Do you have a sample of the file we could see?
Sample of which file?. if you mean the text file one want to read then simple create a text file with 1 item per line. Yes this method is so quick.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|