I have over 9,00,000 records in my Access database but only a fraction of that is being displayed in the listbox. How Many Rows Can A Listbox Hold? Around 65K is the answer I go
I'm not sure what the exact limit is (The url provided below gives some suggestions) I think the number of items you want to populate the listbox with will probably slow your computer down alot if it's populating it with that many records.
Maybe you should consider using a different control that allows paging like a DataGrid or something similar to display 100 results at a time?
This link might be useful to you: http://codeguru.earthweb.com/forum/showthread.php?p=1715288
Creating datagrid with paging: http://support.microsoft.com/kb/305271
There is a bug in the native listbox control that was introduced at Vista time and is still present in Win7. It prevents you from scrolling properly past 65536 + number of visible items. The most visible part of the bug, beyond not seeing the later items, is the scrollbar thumb jumping back when you drag it to the bottom.
This bug doesn't get put to the test very often. Nobody ever expects his user to have enough patience to claw through tens of thousands of items. Such a program gets uninstalled quickly. ListBox capacity is otherwise only limited by the amount of available virtual memory. If you really want to pursue this then use ListView or DataGridView.
I've found it preferable to use DataGridView over ListBox in winforms. The key is to use VirtualMode. I'd derive from DataGridView similar to:
class CustomDgv : DataGridView { public CustomDgv() { this.BackgroundColor = SystemColors.Window; this.BorderStyle = BorderStyle.None; this.Dock = DockStyle.Fill; this.MultiSelect = false; this.AutoGenerateColumns = false; this.RowHeadersVisible = this.AllowUserToResizeRows = false; this.ReadOnly = true; this.AllowUserToAddRows = this.AllowUserToDeleteRows = false; this.CellBorderStyle = DataGridViewCellBorderStyle.None; this.VirtualMode = true; this.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.RowTemplate.Height = this.FontHeight + this.FontHeight / 2; } }
and then implement the virtual part accordingly.