| | |
Trying to speed up GUI response time - Combobox SelectIndexValue event slows down app
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Sep 2006
Posts: 88
Reputation:
Solved Threads: 0
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:
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!
Each code snippet that selects the next level (template -> customer; customer -> item) is stored in a separate procedure:
VB.NET Syntax (Toggle Plain Text)
Private Sub SelectTemplate() 'User selects the template desired from the drop down list Try Select Case cboTemplate.Text Case Is = "South" SQL_Text = "SELECT itemno, [item desc], barcode, cat, baseunit, stockunit FROM SBI_SOUTH_CUST_ITEMS" End Select RegionString = SQL_Text Catch ex As Exception MessageBox.Show("Error:" & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub
VB.NET Syntax (Toggle Plain Text)
Private Sub PopulateCustList() 'Shows list of customers in Customers drop down list Dim SelectCust As String Try SelectCust = "SELECT * FROM OTM_SOUTH_CUSTOMERS" Dim SQLCom As New SqlCommand(SelectCust, SQLCon) da = New SqlDataAdapter(SelectCust, SQLCon) da.Fill(Custds, "cust") CustomerLoading = True 'Set flag on cboCustomer.DataSource = Custds.Tables("cust") cboCustomer.DisplayMember = "name" CustomerLoading = False 'Set flag off Catch ex As Exception MessageBox.Show("Error:" & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try
VB.NET Syntax (Toggle Plain Text)
Private Sub ShowCustomerDetails() 'Show items details for specific customers in Items drop down list Dim da As SqlDataAdapter Dim dt As New DataSet Try Dim SQLCom As New SqlCommand(SQL_Text, SQLCon) da = New SqlDataAdapter(SQL_Text, SQLCon) da.Fill(dt, "details") dgView.DataSource = dt.Tables("details") dgView.AutoResizeColumns() ItemLoading = True cboItem.DataSource = dt.Tables(0) cboItem.DisplayMember = "item desc" ItemLoading = False Catch ex As Exception MessageBox.Show("Error:" & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try 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!
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: if statement problems
- Next Thread: loop through properties?
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account application array basic beginner browser button buttons center check click code combo crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel exists fade file-dialog filter forms ftp generatetags hardcopy html images input insert intel listview module monitor net networking number open output panel passingparameters picturebox picturebox2 port print printing problem project regex right-to-left searchvb.net select serial settings shutdown socket sqldatbase sqlserver survey tcp temperature text textbox timespan toolbox transparency trim txttoxmlconverter user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year





