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!
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.
Re: Thousands of Rows in a Listbox- Visual Basic 2010
Quote:
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.
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
Re: Thousands of Rows in a Listbox- Visual Basic 2010
Quote:
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?
Re: Thousands of Rows in a Listbox- Visual Basic 2010
Quote:
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.