Getting DisplayMember Data From a CheckedListBox

Posted by bradc on 08-May-2009 19:53

Hello,

I have a bound CheckedListBox, and I'm trying to retrieve the checked value. It works when I manually populate the collection, but when I populate it with a binding source I can only retrieve Progress.Data.netuia. I'm probably missing something obvious here. Could someone point me in the right direction?

Binding:


CREATE QUERY hDbQuery.
hDbQuery:SET-BUFFERS(BUFFER ttDb:HANDLE).
hDbQuery:QUERY-PREPARE("PRESELECT EACH ttDb").
hDbQuery:QUERY-OPEN.
       
rBindSDB = NEW Progress.Data.BindingSource(hDbQuery).
cbDbList:DataSource = rBindSDB.
cbDbList:DisplayMember = "dbase-name":U.
cbDbList:ValueMember = "dbase-name":U.

Event:

DO viCount = 0 TO cbDbList:CheckedItems:Count - 1:

  MESSAGE cbDbList:CheckedItems[1] viCount VIEW-AS ALERT-BOX.

END.

All Replies

Posted by Admin on 09-May-2009 14:09

The Progress.Data.netuia object you are seing seems to part of the bridge components, something like a dummy type used to represent an ABL record (buffer) to the .NET side. But AFIAK there is no possibility to use that object to get record values. At least no one that is documented - and so you can't count that these internals won't change.

Therefor the CheckedItems (a list of Progress.Data.netuia objects) won't help. What does work is the following using the CheckedIndices property. That property returnes a list of the record positions that are checked. You can use those position and assign them to the Position property of the bindingSource. Then you can either directly access the field from the query buffer or use the InputValue of the BindingSource.

     DO viCount = 0 TO checkedListBox1:CheckedIndices:Count - 1:

            iIndex  = checkedListBox1:CheckedIndices[viCount] .

            bindingSource1:Position = iIndex .

            

            MESSAGE Salesrep.RepName SKIP

                    bindingSource1:InputValue["RepName"] VIEW-AS ALERT-BOX.

       

        END.

Posted by bradc on 09-May-2009 15:10

mikefe wrote:

The Progress.Data.netuia object you are seing seems to part of the bridge components, something like a dummy type used to represent an ABL record (buffer) to the .NET side. But AFIAK there is no possibility to use that object to get record values. At least no one that is documented - and so you can't count that these internals won't change.

Therefor the CheckedItems (a list of Progress.Data.netuia objects) won't help. What does work is the following using the CheckedIndices property. That property returnes a list of the record positions that are checked. You can use those position and assign them to the Position property of the bindingSource. Then you can either directly access the field from the query buffer or use the InputValue of the BindingSource.

     DO viCount = 0 TO checkedListBox1:CheckedIndices:Count - 1:
            iIndex  = checkedListBox1:CheckedIndices[viCount] .

            bindingSource1:Position = iIndex .
            
            MESSAGE Salesrep.RepName SKIP
                    bindingSource1:InputValue["RepName"] VIEW-AS ALERT-BOX.
       
        END.

Thanks Mike.

That was exactly what I was looking for.

This thread is closed