pb中怎么获取数据窗口的列名

pb中怎么获取数据窗口的列名
2009年04月18日 星期六 16:27

Getcolumn 得到的是当前powerobject的字段的数量。

调用语法: getcolumns ( powerobject apo_data, ref string as_columns[], ref string as_error )

Int li_colcount,i

//取列数

Choose Case TypeOf(apo_data)

         Case datawindow!

                   uo_datawindow_cics ldw

                   ldw = apo_data

                   li_colcount = Integer(ldw.Describe("DataWindow.Column.Count"))

         Case datawindowchild!

                   datawindowchild ldwc

                   ldwc = apo_data

                   li_colcount = Integer(ldwc.Describe("DataWindow.Column.Count"))

         Case datastore!

                   uo_datastore_cics lds

                   lds = apo_data

                   li_colcount = Integer(lds.Describe("DataWindow.Column.Count"))

         Case Else

                   as_error = '调用GetColumns时入参错误:powerobject的类型不正确'

                   Return -1

End Choose

If Not li_colcount > 0 Then

         as_error = '取数据窗口的列数不成功!'

         Return -1

End If

 

//取列名

String columnnames[],ls_colname

For i = 1 To li_colcount

         Choose Case TypeOf(apo_data)

                   Case datawindow!

                            ls_colname = ldw.Describe("#" + String(i) +".Name")

                   Case datawindowchild!

                            ls_colname = ldwc.Describe("#" + String(i) +".Name")

                   Case datastore!

                            ls_colname = lds.Describe("#" + String(i) +".Name")

         End Choose

        

         If IsNull(ls_colname) Or ls_colname = '?' Or ls_colname = '!' Then

                   as_error = '调用GetColumns,取数据窗口的列名称不成功:'+String(i)

                   Return -1

         End If

         as_columns[i] = Upper(ls_colname)

Next

你可能感兴趣的:(PowerBuilder)