Search code examples
powerbuilderdatawindow

Get objects of DataWindow band


How can i get an array of all objects in specific band, Detail or Header for example?

I success to get all objects using:

dw_1.Describe("datawindow.objects")

Solution

  • You need to get the datawindow.visualobjects property that lists all the visible objects and for each object, you ask object_name.band to check if you want it.

    An example that reuses the PbniRegex (that provides the uo_regex object in the code below) to simplify the properties parsing :

    public function long of_get_band_controls (string as_band_name, ref string as_controls[]);
    string ls_empty[]
    int i, j
    as_controls[] = ls_empty[]
    
    uo_regex lnv_regex
    lnv_regex = create uo_regex
    lnv_regex.initialize( "([^\t]+)", true, false)
    i = lnv_regex.search( describe("Datawindow.visualobjects") )
    for j = 1 to i
        if describe( lnv_regex.match( j ) + ".band" ) = as_band_name  then
            as_controls[ upperbound(as_controls[])+1 ] = lnv_regex.match( j )
        end if
    next
    destroy lnv_regex
    
    return upperbound( as_controls[] )
    end function
    

    That code comes from a datawindow herited object, hence it gets direct access to the describe method.