What's the fastest way to populate a combo box in C #?
Your fastest way will probably either bind to the DataReader , or iterate over the DataReader and use a method Add()
for the ComboBox. Anyway, the key is not whether you are binding or iterating (I haven't used these tools and therefore can't tell you which is faster), the key is using the DataReader.
Using a DataSet, you are loading and populating a rather heavy data object. If you notice speed issues, this is probably the culprit. Just switching to DataReader (using Add()
or binding) will probably give you a boost.
Of course, all of this assumes that you see the speed issue in the first place. If you donβt, and no one is complaining about the speed of your application, and your application does not have predicted growth, which could cause a problem, then stay on your current path! "Premature optimization is the root of all evil."
source to share