Solved

Combobox

Posted on 1998-05-30
7
348 Views
Last Modified: 2010-05-03
I have a combobox/listbox in a form and I want to fill the list with > 1000 items when the form loads. However, this process is very slow, it takes a few seconds before the form finish loading. Is there any way to improve this?
Loading all form at startup is not a good option for me because sometimes I need to create new instances of the forms.
0
Comment
Question by:leeal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:JayMerritt
ID: 1462108
What's taking the longest time, the database lookup or the AddItems?

Is the data static or dynamic?

Do you use the same control and values on each form?


0
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 50 total points
ID: 1462109
Use SendMessage with WM_INITSTORAGE to init the storage buffer, and LockWindowUpdate to disable the refresh while you're adding the items
0
 
LVL 1

Author Comment

by:leeal
ID: 1462110
MikeP, can you give me more detail information about the WM_INITSTORAGE message?
I can't find it in API Viewer. Thanks.

JayMerritt, AddItems is taking the longest time. Data is dynamic. Each form use different control.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 8

Expert Comment

by:MikeP090797
ID: 1462111
Sorry, it's CB_INITSTORAGE (&H0161)
0
 
LVL 1

Author Comment

by:leeal
ID: 1462112
MikeP, I just added the CB_INITSTORAGE message and LockWindowUpdate but it only improve the speed very little. So I tried to use the CB_ADDSTRING and CB_SETITEMDATA messages to add items instead of using Combo1.additem and Combo1.itemdata and it's twice as fast, but still I can feel the lag when the form loads. Is there anything else I could do to make it even faster? Here's a part of my code:

    Window_LockUpdate Me
    Combo1.Clear
'-- Combo_InitStorage calls the CB_INITSTORAGE message --
    Combo_InitStorage Combo1, Rst.RecordCount, Rst("Field2").Size + Rst("Field1").Size
    cbohWnd = Combo1.hWnd
    Do Until Rst.EOF
        NewIndex = SendMessageByString(cbohWnd, CB_ADDSTRING, 0&, Rst("Field2"))
        Call SendMessageByString(cbohWnd, CB_SETITEMDATA, NewIndex, Rst("Field1"))
        'With Combo1
            '.AddItem Rst("Field2")
            '.ItemData(.NewIndex) = Rst("Field1")
        'End With
        Rst.MoveNext
    Loop
    Rst.Close
    Window_UnLockUpdate

0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1462113
If you put that in your form_load event, make the first line Me.Show to show the form before you add the items, so the user will know your program isn't dead. Besides that, I don't think there is anything you can do.
0
 
LVL 1

Author Comment

by:leeal
ID: 1462114
Thanks.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 73
Using "ScreenUpdating" 6 88
How to set the sa password in a vb6 code for sql connection 9 71
Spell Check in VB6 13 151
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question