Question ComboBox OnDataSourceChanged event takes a long time

GTA_doum

New member
Joined
Nov 28, 2012
Messages
2
Location
St-Colomban, Qc
Programming Experience
10+
Hello,

I'm transferring my code from Outlook VBA to VSTO VB.Net. I'm using a ComboBox on a form, and on those two lines, when preparing the ComboBox from code, it takes too much time, making the form unusable:

ComboBox_multi_colonnes_Projet.DataSource = ProjetslisteBindingSource
ComboBox_multi_colonnes_Projet.ValueMember = "N°"

The Binding source is a query selecting four fields from one table. The query takes one second to run with SQL server management studio, and returns 28000 rows.

Any suggestions to make it faster?

Funny thing is that in VBA, loading the same data within a ComboBox would take less than 3 seconds:numbness:! Ah the mistery of upgrading to new technologies...
 
The first thing to do is to work out exactly where the time is. The BindingSource is not a query. You would presumably be executing a query to populate a DataTable, binding that to the BindingSource and then binding that to the ComboBox. Exactly how long does each part take? You can use the Stopwatch class to get the timings.
 
The BindingSource is declared on the form, which is a pointer to a DataSet declared within the project. Within the DataSet, there is a query with a TableAdapter, which I'm using for the BindingSource.
When doing step by step debugging, pressing F8 over those two lines takes a long time to get control back:
Within the ComboBox class definition, event OnDataSourceChanged: MyBase.OnDataSourceChanged(e)
Within the form load event: ComboBox_multi_colonnes_Projet.ValueMember = "N°"
 

Latest posts

Back
Top