Search code examples
listdropdownpowerbuildergetvalue

Powerbuilder get selected value from a dropdown list


How can I get the value I've selected in a dropdown list?

I've tried something like this but it won't work, ls_est_an is null:

ll_row = dw_est_an.rowcount()
dw_est_an.GetChild( "est_an" , dddw )
ls_est_an = dw_est_an.object.est_an[ll_row]

Solution

  • You can use the GetSelectedRow method on the datawindow child.

    In your example you are getting the value of 'est_an' for the last row in the datawindow 'dw_est_an'.

    To get the value of the selected row in the dropdown datawindow you can use something like:

    long ll_dddwrow
    string ls_val
    ll_dddwrow = dddw.getselectedrow(0)
    IF ll_dddwrow > 0 THEN
       ls_val = dddw.getitemstring(ll_dddwrow, 'columnname')
    END IF
    

    This assumes whatever column in the dropdowndatawindow object is of type string.