Selected, SelectedId
These properties tell you which items in a list or combo are highlighted.
Usage |
lIsHighlighted = oObject.Selected( nIndex ) oObject.Selected( nIndex ) = lIsHighlighted lIsHighlighted = oObject.SelectedId( nItemId ) oObject.SelectedId( nItemId ) = lIsHighlighted |
In VFP 3, SelectedId doesn't work at all. Ever. No matter what's highlighted or which value you check, SelectedId is always .F. Unless you explicitly set it to .T. But that doesn't do much good, because the item still doesn't get highlighted. In addition, neither of these properties works for combos in VFP 3. Both bugs are fixed in VFP 5. |
Example |
* Set up a multiselect listbox with Employees * Preselect all those located in the USA * Set these properties in the Prop Sheet MultiSelect = .T. RowSourceType = 2 && Alias RowSource = "Employee" ColumnCount = 3 ColumnWidths = 80,40,70 * In the Init for the list: LOCAL nCount SELECT Employee nCount = 1 SCAN IF Country = "USA" This.Selected[nCount] = .T. ENDIF nCount = nCount + 1 ENDSCAN |
See Also |
AddItem, ComboBox, ListBox, ListIndex, ListItemId, MultiSelect |