C#:How to load max no of records in a combobox(more than 40000)
-
hi I am using a combobox to load items using datatable. i am using sqlserver2005.when i tried to load a count of 32500 rows in a combobox , my application hangs more than for 5 min. Any body give me solution. Below is my code:
private void _popItemCombo() //To load itemcode combobox { clsGrpObj = new clsGroupManip(); clsDataAccObj = new clsGloDataAcces(); //code to populate datatable Item table dtItem = new DataTable(); //stores item * datas dtItem = clsGrpObj._selItem_Assembly(); for (int i = 0; i < dtItem.Rows.Count - 1; i++) { string item = dtItem.Rows[i]["ItemCode"].ToString(); cmbItemCode.Items.Add(item); // code to pop combobox with datas. } }
help me, Thank ukssk
-
hi I am using a combobox to load items using datatable. i am using sqlserver2005.when i tried to load a count of 32500 rows in a combobox , my application hangs more than for 5 min. Any body give me solution. Below is my code:
private void _popItemCombo() //To load itemcode combobox { clsGrpObj = new clsGroupManip(); clsDataAccObj = new clsGloDataAcces(); //code to populate datatable Item table dtItem = new DataTable(); //stores item * datas dtItem = clsGrpObj._selItem_Assembly(); for (int i = 0; i < dtItem.Rows.Count - 1; i++) { string item = dtItem.Rows[i]["ItemCode"].ToString(); cmbItemCode.Items.Add(item); // code to pop combobox with datas. } }
help me, Thank ukssk
-
You should use cmbItemCode.DateSource = dtItem and set the DisplayMember and ValueMember instead. Any auto search on the combobox? I would have to scroll 30000 rows on 8 items drop down to select a customer.... :)
-
hi darkelv just i tried that , it also takes exactly 6 seconds. If i ignore that i am experiencing the same trouble in DataGridview combobox column. Can u tell me how to overcome that . Thank u for ur quick response kssk
senthil
Loading 30,000 items into a combo box is plainly not the right thing to do. A combo box is used to select from, with this many items it will be, to all intents, unusable. You need to rethink what you are trying to achieve. Can you filter your list in some way?
Bob Ashfield Consultants Ltd
-
hi darkelv just i tried that , it also takes exactly 6 seconds. If i ignore that i am experiencing the same trouble in DataGridview combobox column. Can u tell me how to overcome that . Thank u for ur quick response kssk
senthil
Like Ashfield said, there's no way around it. You just have to load less data. The problem will be worse if you do it in the DataGridViewComboboxColumn. You can subclass the combobox, let use enter the beginning letter of the item, and handle the text change or something. Once the control detected that use entered something, populate the combobox with the data beginning with the letter user entered, etc. Or use a picker dialog.