Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Populating a dropdown list on a form
Message
From
03/12/2001 05:21:58
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/12/2001 12:26:35
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00588405
Message ID:
00588612
Views:
21
>I have a VFP form which has a dropdown list populated from an array which takes the data from a table. There are about 1000 entries. When my form instantiates there is a long delay with just the form border showing and not the other controls on the form. I am trying to get a much snappier appearance but I cannot work out how to delay the form showing until the array has been populated.
>
>Can anyone advise?
>TIA
>Barry Sutton

Barry,
As you mentioned somewhere else FoxyClasses has 2 moverlists. One uses native listbox which is slow by nature (that sample has less than 1K recs) and the other uses grids (11K+ recs in sample - does extra handling in selecting requested recs which I even couldn't dare to do in listbox version).
With listbox and combos things get worse if you use array or additem. Answer is hidden in your question IMHO. You take the array from a table. Instead make rowsource the SQL itself w/o taking into an intermediate array to populate :
*Combo.init
with this
 .RowSourceType = 3
 .RowSource = "select field1,...fieldn from myTable "+;
            "where SomeCriteria "+;
            "order by SomeOrder "+;
            "into cursor crsMyCursor" && Use a unique cursor name
 .Columncount = 2 && Set columncount to your wish 
 && independent from real field count
 .BoundColumn = 2 && For example
 .BoundTo = .t.   && Especially important if bound to a numeric field
 .ColumnWidths='100,50'
 .Controlsource = '' && Set whatever it's
endwith
Now you have a cursor type rowsource. When you need to query a value you don't need to know its column in combo nor it should be part of combo columns. ie: If your SQL was :

"select * from employee ..." and columncount is set to 2,

In order to get emp_id value you don't need to know its column pos in combo. Just get it with crsMyCombo.Emp_id. In the same manner thought you only show 2 columns in combo you can access all fields of employee :
crsmyCombo.ReportsTo would give you reportsto value for selected combo row item.

Apart from this great advantage this type of combo loading is instant.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform