procedure Memo31OnAfterData(Sender: TfrxComponent);
var
  CI:boolean;
begin
  CI:=true;
  if Pos('200',Memo31.Memo.Text)then
  begin
  if CI=true then
  begin
  CI:=false;
  Memo31.Color:=claqua;
  end
  else
  begin
  Memo31.Color:=clcream;
  CI:=true;
  end;
  end;
  if Pos('IC',Memo31.Memo.Text) then
  begin
  if CI=true then
  begin
  Memo31.Color:=claqua;
  CI:=false;
  end
  else
  begin
  Memo31.Color:=clcream; 
  CI:=true;
  end;
  end;
end;
这是写在fastreport的脚本程序。目的是使根据memo31显示的内容(来自adoquery)给memo31赋不同的背景色。
程序运行的效果应该是。
200 //背景色是claqua
ic  //背景色是clcream
以上是同时显示的,不是只有200而没有ic,或只有ic而没有200
不知为什么,程序运行的效果却是:
200 //背景色是claqua
ic  //背景色是claqua
也就是说在第二个if语句里虽然有CI:=false语句却CI仍然为True;导致了第四个if语句成立,才有
ic  //背景色是claqua?
也就是说在第二个if语句里虽然有CI:=false语句但不起作用????
百思不得其解

解决方案 »

  1.   

    看不明白要实现什么,就两个条件有这样复杂?~~procedure Memo31OnAfterData(Sender: TfrxComponent);
    begin
      if Pos('200', Memo31.Memo.Text) > 0 then
        Memo31.Color := clAqua;
      if Pos('IC', UpperCase(Memo31.Memo.Text)) > 0 then
        Memo31.Color := clCream;
    end;
      

  2.   

    在数据库中有表:内容如下:
    类型  //字段名
    200   //内容
    IC    //内容fastreport设计如下:
    memo1 //里面有固定值“类型”
    memo2 //值从adoquery传过来[*."类型"]现在我通过select * from 表名,将表中的东东在fastreport里显示。
    显示内容应该是:
    类型    //memo1
    200     //memo2  
    IC      //memo2现在我想
    类型    //memo1
    200     //memo2  此处的memo背景色为claqua
    IC      //memo2  此处的memo背景色为clcream也就是说两种色交替出现