Listbox extremly slow loading

3 posts, 0 answers
  1. Lovsten
    Lovsten avatar
    72 posts
    Member since:
    Aug 2007

    Posted 17 Oct 2007 Link to this post

    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. MattLynch
    MattLynch avatar
    20 posts
    Member since:
    Jan 2007

    Posted 18 Oct 2007 Link to this post

    Hi Lovsten,

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

    Regards,

    Matt

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Lovsten
    Lovsten avatar
    72 posts
    Member since:
    Aug 2007

    Posted 19 Oct 2007 Link to this post

    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.
Back to Top