Logo

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.

MultiSelect

This property determines whether list boxes can have multiple items highlighted at once.

Usage

lstList.MultiSelect = lMultipleItems
lMultipleItems = lstList.MultiSelect

When MultiSelect is .T., you can use all the standard Windows methods for choosing one or more items. These include Shift+Clicking at the beginning and end of a range to highlight everything in between, and Ctrl+Click to select and deselect individual items. Shift+Spacebar and Ctrl+Spacebar perform the same functions, and Shift plus the cursor control keys can highlight a range to add.

In VFP 3, there is a limit of 60 selected items at once. You can put more than 60 items in the list and you can try to select them, but as you select more items, once you get past 60, your first selections get deselected. We weren't at all surprised that this bug was fixed fast. (It's there in VFP 3.0 and 3.0b, but fixed in 5.0 and later.)

You can find out which items are highlighted at any time by checking the Selected or SelectedId property. In fact, you can make items be highlighted by setting Selected to .T. for those items.

VFP 3 has another multi-select bug, too. When RowSourceType is 2, 3, 4 or 5 (that's Alias, SQL, Query and Array), a previously selected item doesn't always deselect when it should. Here's the simplest example. Run a form with a multi-select list of one of these types and a button. Click an item in the list. Now click the button. Now click a different list item. We see two highlighted items. This nasty bug was also fixed quickly.

Example

frmMyForm.lstMyList.MultiSelect = .T.

See Also

ComboBox, ListBox, RowSourceType, Selected, SelectedId