如何在下拉菜单中加载数据窗口中的一个字段

foxhomes 2006-12-06 03:43:34
小弟是新手,正在用PB做一个查询系统,我想在窗口打开的时候在下拉菜单中自动加入数据窗口中一个字段的所有内容,请问高手该怎么做?万分感谢
...全文
195 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
leyueming 2006-12-06
  • 打赏
  • 举报
回复
固定的吗??
固定的话,建表,选择你要显示的字段
下拉数据窗口中选择表名,和要显示的列,传的值就行了
rightyeah 2006-12-06
  • 打赏
  • 举报
回复
$PBExportHeader$u_dropdowndatalist.sru
$PBExportComments$DropDownDataList~r~nUsage:~r~nRetrieve(sqlca,"select name,id from users")~r~nll_id=GetData()~r~n
forward
global type u_dropdowndatalist from dropdownlistbox
end type
end forward

global type u_dropdowndatalist from dropdownlistbox
int Width=247
int Height=228
int TabOrder=10
BorderStyle BorderStyle=StyleLowered!
boolean VScrollBar=true
long TextColor=33554432
int TextSize=-12
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
global u_dropdowndatalist u_dropdowndatalist

type variables
datastore ids
end variables

forward prototypes
public function any getdata ()
public function long retrieve (ref transaction ao_sqlca, string as_sqlselect)
end prototypes

public function any getdata ();any la_ret
long i
setnull(la_ret)
if this.text<>"" then
i=ids.find("#2='"+this.text+"'",1,ids.rowcount())
//ids.filter()
if i>0 then
la_ret=ids.Object.data[i, 1]
end if
end if
return la_ret

end function
public function long retrieve (ref transaction ao_sqlca, string as_sqlselect);long ll,i
string errors,ls_sql
//根据sql语句产生数据窗口
ls_sql = sqlca.SyntaxFromSQL(as_sqlselect, 'style(type=grid)',errors)
//sql语句有错误
if len(errors) > 0 then
messagebox('错误1', errors)
return -1
end if
//根据语法动态创建数据窗口
ids.create(ls_sql,errors)
if len(errors) > 0 then
messagebox('错误2', errors)
return -1
end if
ll =ids.settransobject(sqlca)
//messagebox('',string(ll)+sqlca.sqlerrtext)

ll = ids.retrieve()
ll = ids.rowcount()
//messagebox('',string(ll)+sqlca.sqlerrtext+ids.getsqlselect())
//把数据插入控件
for i = 1 to ll
this.additem(string(ids.Object.Data[i,2]))
next
//成功返回0
return ll

end function
event destructor;if isvalid(ids) then
destroy ids
end if

end event

event constructor;ids=create datastore

end event

eviler 2006-12-06
  • 打赏
  • 举报
回复
我也是新手
如果下拉菜单是出现在数据窗口中,就中下拉数据窗口
如果不是就直接用sql语句提取数据添加到下拉菜单中

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧