我觉得应该是条件语句的问题
不过没看出来
procedure TMAINFORM.DataSetBroker1AfterOpen(DataSet: TDataSet);
var
i,ii: integer;
s:String;
begin
ii:= 0;
for i:=0 to ((DataSetBroker1.DataSet.FieldCount div 2)-1) do
begin
s:= TSQLDataSet(DataSetBroker1.DataSet).BizFields[ii].DisplayName;
if i<>0 then
DataGrid1.Bands.Add;
if StringUtils.Pos('_',s)=0 then
DataGrid1.Bands.Items.Caption := '商品信息'
else if StringUtils.Pos('*',s)=0 then
DataGrid1.Bands.Items.Caption := StrUtils.leftStr(TSQLDataSet(DataSetBroker1.DataSet).BizFields[ii].DisplayName,6)
else
DataGrid1.Bands.Items.Caption := '合计';
ii:=ii+2;
end;
ii:=0;
for i:=0 to DataGrid1.ColumnCount-1 do
begin
if (Trunc(i/2)<>0) then
if (i mod 2 =0) then
ii:=ii+1;
DataGrid1.Columns.BandIndex := ii;
end;
for i:=0 to DataGrid1.ColumnCount-1 do
begin
s:= TSQLDataSet(DataSetBroker1.DataSet).BizFields.DisplayName;
if StringUtils.Pos('_',s)>0 then
TSQLDataSet(DataSetBroker1.DataSet).BizFields.DisplayName:= StrUtils.rightStr(s,4)
end;
end; |