How Many Rows Can A Listbox Hold? Windows Form Application

后端 未结 3 898
一向
一向 2021-01-28 09:51

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

3条回答
  •  有刺的猬
    2021-01-28 10:47

    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.

提交回复
热议问题