Trying to speed up GUI response time - Combobox SelectIndexValue event slows down app

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 88
Reputation: bajanpoet is an unknown quantity at this point 
Solved Threads: 0
bajanpoet bajanpoet is offline Offline
Junior Poster in Training

Trying to speed up GUI response time - Combobox SelectIndexValue event slows down app

 
0
  #1
Nov 26th, 2008
I realize that the response time of my GUI is extremely slow! I have three combo boxes - I want the user to select a template from one drop down list, which will populate the second drop down list with customers related to that template. When a customer is selected, the third drop down list is to be populated with items related to that customer.

Each code snippet that selects the next level (template -> customer; customer -> item) is stored in a separate procedure:

  1. Private Sub SelectTemplate()
  2. 'User selects the template desired from the drop down list
  3. Try
  4. Select Case cboTemplate.Text
  5. Case Is = "South"
  6. SQL_Text = "SELECT itemno, [item desc], barcode, cat, baseunit, stockunit FROM SBI_SOUTH_CUST_ITEMS"
  7. End Select
  8. RegionString = SQL_Text
  9. Catch ex As Exception
  10. MessageBox.Show("Error:" & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  11. End Try
  12. End Sub

  1. Private Sub PopulateCustList()
  2. 'Shows list of customers in Customers drop down list
  3. Dim SelectCust As String
  4. Try
  5. SelectCust = "SELECT * FROM OTM_SOUTH_CUSTOMERS"
  6. Dim SQLCom As New SqlCommand(SelectCust, SQLCon)
  7. da = New SqlDataAdapter(SelectCust, SQLCon)
  8. da.Fill(Custds, "cust")
  9.  
  10. CustomerLoading = True 'Set flag on
  11. cboCustomer.DataSource = Custds.Tables("cust")
  12. cboCustomer.DisplayMember = "name"
  13. CustomerLoading = False 'Set flag off
  14.  
  15. Catch ex As Exception
  16. MessageBox.Show("Error:" & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  17. End Try

  1. Private Sub ShowCustomerDetails()
  2. 'Show items details for specific customers in Items drop down list
  3. Dim da As SqlDataAdapter
  4. Dim dt As New DataSet
  5.  
  6. Try
  7. Dim SQLCom As New SqlCommand(SQL_Text, SQLCon)
  8. da = New SqlDataAdapter(SQL_Text, SQLCon)
  9. da.Fill(dt, "details")
  10. dgView.DataSource = dt.Tables("details")
  11. dgView.AutoResizeColumns()
  12. ItemLoading = True
  13. cboItem.DataSource = dt.Tables(0)
  14. cboItem.DisplayMember = "item desc"
  15. ItemLoading = False
  16. Catch ex As Exception
  17. MessageBox.Show("Error:" & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  18. End Try
  19. End Sub

Those procedures are called from the SelectIndexChanged events of cboTemplate and cboCustomer, respectfully.

I find that in my testing, these SelectIndexChanged events are fired numerous times - every time I add a DataSource, every time I add a DisplayMember.

I need to code this logic in such a way that the GUI does not hang for 5 seconds each time a user makes a change. What can I use other than SelectIndexChanged?

(One way I tried to get around this is the boolean CustomerLoading and ItemLoading. I change them to True when the datasource and displaymember are being loaded and false otherwise, and try to skip the myriad times the procedures are fired by testing for a False value in the SelectIndexChanged, but either I'm not doing it right, or I'm missing something.)

Please assist!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC