首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

combobox的有关问题,大家是如何解决的哈

2012-03-13 
combobox的问题,大家是怎么解决的哈Delphi(Pascal) codewith datamodule1.qdepartment dobeginclosesql.c

combobox的问题,大家是怎么解决的哈

Delphi(Pascal) code
with datamodule1.qdepartment do    begin        close;        sql.clear;        sql.add('select * from department order by departmentid');        open;    end;    while not datamodule1.qdepartment.eof do    begin        combobox4.items.Add(datamodule1.qdepartment.fieldbyname('departmentname').Value);        datamodule1.qdepartment.Next; //数据后移    end;


我通过如上代码将department表中的部门名循环添加到combobox4中..

在一个信息录入窗口中,我通过选取combobox中的部门名,怎么将该部门名岁对应的部门号插入到一个表(该表含有部门号字段,即部门号字段为该表的外键)中呢?...

//不要再告诉我又循环娶出来做比较然后再确定部门号啊,那太晕了哈..



department table: (departmentid,departmentname,remark)

[解决办法]
combobox4.items.AddObject(datamodule1.qdepartment.fieldbyname('departmentname').Value,TObject(编号)); 
用AddObject添加

Integer(combobox4.Items.Objects[combobox4.ItemIndex]
这个是得到编号

热点排行