if strngrdExcelFiles1.Cells[j, i] <> strngrdExcelFiles2.Cells[j, i] then
        begin
          with strngrdExcelFiles1 do
          begin
            str := strngrdExcelFiles1.Cells[j, i];
            Rect := strngrdExcelFiles1.CellRect(j, i);
            strngrdExcelFiles1.Canvas.Brush.Color := clBlue;
            Canvas.FillRect(Rect);
          end;
        end;我是先赋值给stringgrid然后再进行比对,发现不一样的,通过不同颜色显示出来,现在颜色能显示了,但内容看不到了,是什么原因呢? 在线等啊。

解决方案 »

  1.   

    好了,好了,自己搞定了。最后加一行。
    if strngrdExcelFiles1.Cells[j, i] <> strngrdExcelFiles2.Cells[j, i] then
      begin
      with strngrdExcelFiles1 do
      begin
      str := strngrdExcelFiles1.Cells[j, i];
      Rect := strngrdExcelFiles1.CellRect(j, i);
      strngrdExcelFiles1.Canvas.Brush.Color := clBlue;
      Canvas.FillRect(Rect);
      strngrdExcelFiles1.Canvas.textrect(Rect,Rect.left,Rect.Top,strngrdExcelFiles1.Cells[j, i]);
      end;
      end;
      

  2.   

    Canvas.FillRect(Rect);以后用DrawText输出字
      

  3.   

    你得用Canvas.TextOut去输出你的文字
      

  4.   

    写字需要再次画图
    用DrawText和strngrdExcelFiles1.Canvas.textrect画都行