如何实现下面的功能?

xxsteven 2003-08-17 07:19:22
我有一个combobox,我已经实现它下拉了一个数据库里面的字段的数据:程序如下:
combobox2.items.clear;
with table1 do
begin
first;
while not eof do
begin
combobox2.items.add(Table1.FieldByName('qiyecode').asstring);
next;
end;
end;
但现在我想在里面增加一个下拉的items为“增加”,点激它以后可以连接到一个form怎么实现。???请指教。。。。
...全文
21 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
songandlan 2003-08-18
  • 打赏
  • 举报
回复
對於 toyly(李易) 提出的:
万一数据库里也有个字段也有一个字符串叫“增加”呢,为了减少出现此种可能,可增加一些特殊字符

其實有更好的方案如下:

先将ITEMS增加
combobox2.items.clear;
with table1 do
begin
first;
while not eof do
begin
combobox2.items.add(Table1.FieldByName('qiyecode').asstring);
next;
end;
combobox2.items.add('增加');
end;


在combobox2的click事件中
//如果本行是最后一行那麼就可以做樓主想要做的東東了

if combobox2.itemindex=combobox.item.count - 1 then
begin
form:=Tform.create(application) ;//这里是连接FORM的代码
end;
liangzisiyun 2003-08-17
  • 打赏
  • 举报
回复
给一楼加分吧。他的说法应该是可行的。试试看吧。
toyly 2003-08-17
  • 打赏
  • 举报
回复
万一数据库里也有个字段也有一个字符串叫“增加”呢,为了减少出现此种可能,可增加一些特殊字符
Spqk005 2003-08-17
  • 打赏
  • 举报
回复
先将ITEMS增加
combobox2.items.clear;
with table1 do
begin
first;
while not eof do
begin
combobox2.items.add(Table1.FieldByName('qiyecode').asstring);
next;
end;
combobox2.items.add('增加');
end;


在combobox2的click事件中
if combobox2.Text='增加' then
begin
form:=Tform.create(application) ;//这里是连接FORM的代码
end;

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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