Consultor Eletrônico



Kbase P175842: How to set and get the checked status of a given list item in MS CheckedListBox control
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   22/10/2010
Status: Unverified

GOAL:

How to set and get the checked status of a given list item in MS CheckedListBox control

GOAL:

How to check or toggle the checked property of an item in Microsoft's checkedListBox control

FACT(s) (Environment):

Windows
OpenEdge 10.2x

FIX:

If you already know the index of the item in the list, simply use getCheckedItem or setCheckedItem to accomplish this.

FIX:

If you do not know the item description or item index and want to make a list of checked items, loop through the list of checked items using the CheckedItems property:


DEFINE VARIABLE iItem AS INTEGER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE lUnCheck AS LOGICAL NO-UNDO.
DEFINE VARIABLE iItemNo AS INTEGER NO-UNDO.
DEFINE VARIABLE cItemList AS CHARACTER NO-UNDO.

/* Grab the checked items count */
iCount = THIS-OBJECT:checkedListBox1:CheckedItems:Count.

/* Loop through all checked items, get the list item, by description, then find its index with FindString */
DO iItem = 1 TO iCount:
cItemList = cItemList + (IF (cItemList GT "") EQ TRUE lor=#7f0055 size=2>THEN "," ELSE "" ) +
STRING(THIS-OBJECT:checkedListBox1:CheckedItems[iItem - 1]).
END.

MESSAGE "Items: " cItemList " are selected." VIEW-AS ALERT-BOX.

DO iItem = 1 TO NUM-ENTRIES(cItemList):
MESSAGE "Do you wish to deselect item: " ENTRY(iItem,cItemList) "?"
VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE lUnCheck.
IF lUnCheck THEN
THIS-OBJECT:checkedListBox1:SetItemChecked(THIS-OBJECT:checkedListBox1:FindString(ENTRY(iItem,cItemList)),FALSE).
END..