Hello,
I have a form on a VB app that has 2 comboboxes. When I load that form, I need to fill the comboboxes with data from a data table. What I have right now works very well, except for the fact that it is excruciatingly slow since the table has about 24000 records in it. Here's what I have:
Any idea/suggestions on how I can make this more efficient?
Many thanks!
Cheers,
Realm174
I have a form on a VB app that has 2 comboboxes. When I load that form, I need to fill the comboboxes with data from a data table. What I have right now works very well, except for the fact that it is excruciatingly slow since the table has about 24000 records in it. Here's what I have:
Code:
Sub comboPopulate()
Dim dt As New DataTable("From")
dt = TryCast(frmFSEHelper.dgvAirportList.DataSource, DataTable)
If Not dt.Columns.Contains("Description") Then
dt.Columns.Add("Description", GetType(String))
End If
For Each row As DataRow In dt.Rows
row.Item("Description") = row.Item("ICAO") & " - " & row.Item("City") & ", " & row.Item("Country")
Next
'This is to duplicate the Origin combobox to the Destination combobox
If dt.Rows.Count > 0 Then
cmbOrigin.DataSource = dt
cmbOrigin.DisplayMember = "Description" 'What is displayed
cmbOrigin.ValueMember = "ICAO" 'The ID of the row
cmbDestination.DataSource = dt.Copy
cmbDestination.DisplayMember = "Description" 'What is displayed
cmbDestination.ValueMember = "ICAO" 'The ID of the row
End If
End Sub
Any idea/suggestions on how I can make this more efficient?
Many thanks!
Cheers,
Realm174