我想初始化一个CheckListBox,想让它与一个DBGrid关联。
其中每一个Item的值为DBGrid.Colums[i].Title.Caption+'['DBGrid.Colums[i].FieldName+']'
比如:
姓名 [name]
年龄 [age]
其中name,age为表的字段名。而DBGrid已经在DFM文件用Edting DBGrid中设置好了字段
我写的函数是这样的:
procedure InitClbItems(clb:TCheckListbox;dbg:TDBGrid);
var i:integer;
begin
clb.Items.Clear ;
with dbg do
begin
for i:=0 to Columns.Count-1 do
begin
clb.Items.Add(Format('%10s',[Columns[i].Title.Caption])+'['+Columns[i].FieldName+']');
end;
end;
end;
可是程序报异常啊~
其中每一个Item的值为DBGrid.Colums[i].Title.Caption+'['DBGrid.Colums[i].FieldName+']'
比如:
姓名 [name]
年龄 [age]
其中name,age为表的字段名。而DBGrid已经在DFM文件用Edting DBGrid中设置好了字段
我写的函数是这样的:
procedure InitClbItems(clb:TCheckListbox;dbg:TDBGrid);
var i:integer;
begin
clb.Items.Clear ;
with dbg do
begin
for i:=0 to Columns.Count-1 do
begin
clb.Items.Add(Format('%10s',[Columns[i].Title.Caption])+'['+Columns[i].FieldName+']');
end;
end;
end;
可是程序报异常啊~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货