小弟初学Delphi,在Grid++ Report 5.0中有一个报表,此报表有90个格,格内变量为“编号1”到“编号90”,我的Delphi中的DBGrid里显示数据库中编号一列,编号个数为动态的多少不定,我需要把DBGrid中的 编号 导入到 Grid++ Report 5.0中的报表中,多余的要求翻页显示并能够打印,现用法是在Delphi中使用DBGrid语句:
var
i,j,k,l:integer;
i:=DBGrid1.SelectedRows.Count;
k:= i div 90;
for l:=0 to k do
begin
j:=(k*90);
GridppReport1.LoadFromFile('C:\Grid++Report 5.0\Samples\Reports\铁路机车车辆产品交验记录单.grf');
GridppReport1.ParameterByName('轴承编号1').AsString:=DBGrid1.Columns.Grid.Fields[(0+j)].Value;
....
....
GridppReport1.ParameterByName('轴承编号90').AsString:=DBGrid1.Columns.Grid.Fields[(89+j)].Value;
GRDisplayViewer1.Report:= GridppReport1;
GRDisplayViewer1.Start();
急等!!谢谢各位大侠多多指教!
var
i,j,k,l:integer;
i:=DBGrid1.SelectedRows.Count;
k:= i div 90;
for l:=0 to k do
begin
j:=(k*90);
GridppReport1.LoadFromFile('C:\Grid++Report 5.0\Samples\Reports\铁路机车车辆产品交验记录单.grf');
GridppReport1.ParameterByName('轴承编号1').AsString:=DBGrid1.Columns.Grid.Fields[(0+j)].Value;
....
....
GridppReport1.ParameterByName('轴承编号90').AsString:=DBGrid1.Columns.Grid.Fields[(89+j)].Value;
GRDisplayViewer1.Report:= GridppReport1;
GRDisplayViewer1.Start();
急等!!谢谢各位大侠多多指教!
Project zcjc.exe raised exception class EAccessViolation whit message 'Access violation at address 0054E2FA in module ' zcjc.exe. Read of address 00000000'. Process Stopped. Use Step or Run to Continue.
所指向的错误处是第二句,也就是 GridppReport1.ParameterByName('轴承编号2').AsString:=DBGrid1.Columns.Grid.Fields[(1+j)].Value; 句,尝试屏蔽此句,第三句出错,逐一屏蔽,除第一句外所有出现的第二句均报错,全部屏蔽后可正常显示!但是只有第一个数。其他空白。
只需要在DBGrid的OnDblClick事件中如下写即可:procedure DBGrid1.OnDblClick(Sender : TObject);
begin
Edit1.Text := TDBGrid(Sender).SelectedField.Text;
end;
只需要在DBGrid的OnDblClick事件中如下写即可
procedure DBGrid1.OnDblClick(Sender : TObject);
begin
Edit1.Text := TDBGrid(Sender).SelectedField.Text;
end;