Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
At last! This property, added in VFP 6, lets you determine how many items show up when you open a combo box.
cboCombo.DisplayCount = nHowManyItems
nHowManyItems = cboCombo.DisplayCount
By default, when you drop a combo open, seven items show up. If there are fewer than seven items in the list, of course, only that many show. If there are more than seven, you get scroll bars. DisplayCount lets you change all that. Well, actually, not all that—just the magic number.
Why would you want to change DisplayCount? We can think of a few reasons. When the number of items in a combo is large, seven just isn’t very many to show at a time. (Of course, combos aren’t meant for huge lists—asking a user to scroll through hundreds or thousands of items isn’t very good interface design.)
Sometimes, you have a small, fixed list, with more than seven items in the list. Why should a user have to scroll when there are only nine or 10 choices? (Consider the drop-down for RowSourceType in the property sheet, for example.)
Finally, in situations where form real estate is scarce, you may want to limit the number of items that appear at once in order not to obscure some other fields while the user is choosing.
Apparently Microsoft liked DisplayCount in the language so much, they added a similar setting to the IDE in VFP 7. The IDE page of the Options dialog contains the “List Display Count” setting that determines how many items appear in dropdowns within VFP.
ThisForm.cboChoices.DisplayCount = 12