This is a migrated thread and some comments may be shown as answers.

Listbox extremly slow loading

2 Answers 164 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lovsten
Top achievements
Rank 1
Lovsten asked on 17 Oct 2007, 08:38 AM
I list by business objects in a listbox. It find it extremly slow to load.
Here is my code:
                    Dim lngTick As Long = Environment.TickCount  
                    lbxPromotionProduct.BeginUpdate()  
                    Dim prods As ProductROCollection = ProductROCollection.GetProductsRO(_identity.CompanyId)  
                    Debug.WriteLine("Time to Load collection" & vbTab & Environment.TickCount - lngTick)  
                    lngTick = Environment.TickCount  
                    If prods.Count > 0 Then 
                        If optPromotionProductListByName.Checked Then 
                            prods.SortStable("productName", System.ComponentModel.ListSortDirection.Ascending)  
                        Else 
                            prods.SortStable("productRef", System.ComponentModel.ListSortDirection.Ascending)  
                        End If 
                    End If 
                    Debug.WriteLine("Time to SortStable" & vbTab & Environment.TickCount - lngTick)  
                    lngTick = Environment.TickCount  
                    With lbxPromotionProduct  
                        .DataSource = Nothing 
                        .DisplayMember = "productRefName" 
                        .ValueMember = "productRef" 
                        .DataSource = prods  
                        Debug.WriteLine("Time to DataSource" & vbTab & Environment.TickCount - lngTick)  
                        lngTick = Environment.TickCount  
                        If .SelectedIndex > -1 Then .SetSelected(.SelectedIndex, False)  
                        Debug.WriteLine("Time to Selected" & vbTab & Environment.TickCount - lngTick)  
                        lngTick = Environment.TickCount  
                    End With 
                    lbxPromotionProduct.EndUpdate()  
                    Debug.WriteLine("Time to EndUpdate" & vbTab & Environment.TickCount - lngTick)  
 
and the output is:
Time to Load collection 501  
Time to SortStable  110  
Time to DataSource  6820  
Time to Selected    0  
Time to EndUpdate   2213 

We are only talking about 584 records so it's not a huge amont of data.

Any advice?

2 Answers, 1 is accepted

Sort by
0
MattLynch
Top achievements
Rank 1
answered on 18 Oct 2007, 04:29 PM
Hi Lovsten,

Have you tried SuspendLayout() at the top of your code block and ResumeLayout() at the end? 

Regards,

Matt

0
Lovsten
Top achievements
Rank 1
answered on 19 Oct 2007, 05:58 AM
Yes I've tried that. Makes no significant change.

You must have done some sort of performance testing right? You must have seen the same type slow performance when comparing to the MS listbox. Or maybe you don't do performance testing at all?? Doesn't look like it when using your controls. Datagrid is also extremly slow. So slow it's your controls are not usable in a professional application.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Lovsten
Top achievements
Rank 1
Answers by
MattLynch
Top achievements
Rank 1
Lovsten
Top achievements
Rank 1
Share this question
or