procedure Tyw_bjgl_new_fm.DBGridEh1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
strcpbh:string;
begin
strcpbh:=dbgrideh1.Columns.Items[0].DisplayText;
with DBGridEh1.Columns[10].pickList do
begin
clear;
with dm_fm.Query_xl do
begin
close;
sql.clear;
sql.add('select * from cp_bzzl where cp_cpbh='''+strcpbh+'''');
open;
first;
begin
while not Eof do
begin
DBGridEh1.Columns[10].pickList.add(Fieldbyname('bz_bzlx').asstring);
next;
end;
end;
end;
end;
DM_FM.Query_xl.Active:=false;
//////计量单位
begin
with DBGridEh1.Columns[5].pickList do
begin
clear;
with dm_fm.Query_xl do
begin
close;
sql.clear;
sql.add('select * from cyzl_jldw');
open;
first;
begin
while not Eof do
begin
DBGridEh1.Columns[5].pickList.add(Fieldbyname('jldw_jldw').asstring);
next;
end;
end;
end;
end;
DM_FM.Query_xl.Active:=false;
end;
end;
该博客内容涉及在DBGrid控件中处理下拉框数据的加载和更新。当点击DBGrid某一列时,根据选定的值动态从数据库查询相关数据填充到下拉框。首先,通过DBGrid的Columns.Items获取选中项,然后根据获取的值查询'cp_bzzl'表中的数据,将'bz_bzlx'字段添加到列10的pickList。接着,同样方式更新计量单位列5的pickList,从'cyzl_jldw'表中获取'jldw_jldw'字段。
1267

被折叠的 条评论
为什么被折叠?



