• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1002
  • Last Modified:

Fast loading objects in a DataGridViewComboBoxColumn

Hi,
Im currently having a problem about loading 2000 objects inside a DataGridiewComboBoxColumn. The routin im currently using is very slow. I do a foreach-loop in my collection class, and then add the items one by one. I also tried threading (www.codeproject.com/csharp/workerthread.asp) but the problem is the column reacts very late while the thread is not yet finished and also the AutoComplete of the column does not normally work until the thread stops. Any ideas on how to fast load lots of objects inside a DataGridiewComboBoxColumn? Help!
0
manduz_griffus
Asked:
manduz_griffus
  • 2
  • 2
1 Solution
 
JimBrandleyCommented:
It is not clear whether you are adding 2000 rows to the grid, or 2000 items to a single ComboBox.

If the former, you might consider implementing paging for your grid - 2000 is a large number of rows.
If the latter, try
comboboxColumn.Items.AddRange();

Jim
0
 
manduz_griffusAuthor Commented:
hi JimBrandley,

Sorry for the late reply. I tried what you have suggested, using AddRange, passing an array of the 2000 objects. It is very slighty faster, but is there a faster solution? By the way, i am adding 2000 items to a combobox; a DataGridViewComboBoxCell to be precise. Any more ideas?
0
 
JimBrandleyCommented:
AddRange() is as fast as it will go. The root of your problem is just putting too many items in the ComboBox. I would call 100 items a large list for a ComboBox. From the perspective of the user, consider how hard it is to scroll through a list of 100.

I do not know what your application is, but I would expect there might be ways to either page, or perform some grouping, then let the user select the group, and once the group is selected, select from a smaller list that constitutes the membership of that group.

If you can provide a list of some sample data, or a description of the content of the list, I might be able to help more.

Jim
0
 
manduz_griffusAuthor Commented:
Maybe you're right. It is rather incovenient for the user to select an item in a 2000-item combo box. The problem is this combobox is a DataGridViewComboBoxColumn. It is part of a purchase order form where the DataGridView is where the user selects an item, inputs price, etc. The user can type on the DataGridViewComboBoxColumn since AutoComplete is enabled, so selecting an item is not an issue,  loading those items is.

What im planning now is to pre-load an ObjectCollection in the splash screen and when the PO form is loaded, add the ObjectCollection to the DataGridViewColumn.
0
 
AntonioRodrigoCommented:
This solution is not working for me - I need to display all items in my DataGridViewComboBoxColumn and I have more than 1000 of them. In the ComboBox, there is no problem. So, what to do? The issue was also posted to Microsoft directly, years ago, but nothing happened. I've also tried to change my datasource from data table to string array, with the same slow result. I can create an control by myself, but this will take a lot of time. I guess there some way out of this?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now