How to Display Disabled Items in a Combo or List Box

Last reviewed: November 30, 1995
Article ID: Q133743
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

This article shows by example how to disable items in a combo box or list box.

MORE INFORMATION

Combo Box Example

  1. Create a Form with a combo box (either with a style of DropDown Combo or DropDown List).

  2. In the DblClick method of the DropDown Combo or the RightClick method of the DropDown List, place this code:

    This.List(This.ListItemId)='\'

    NOTE: The DblClick method in the DropDown List does not disable the item. That is why a RightClick method is recommended.

  3. In the RowSource for the combo box, place this code:

    SELECT DISTINCT city from customer into cursor MyCity

    NOTE: In general, it doesn't matter what the RowSource or Type are.

  4. In the RowSourceType for the combo box, select 3 - SQL Statement.

  5. Run the Form, and select an item on the list. When the item appears in the combo box, you can disable the item by double-clicking it or by clicking it using the right mouse button.

Possible Enhancements

  • If you want to disable a specific item on the list, you can replace the ListItemId with a specified Item Number.
  • You can use the ComboBox Layout DisabledItemForeColor property to change the color of the disabled item text.


Additional reference words: 3.00 VFoxWin OOP combobox listbox
KBCategory: kbprg kbcode
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 30, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.