请问:我想在程序运行时,在stringgrid的cells中依次输入采来的数据,而当采到当前的一格时,要改变这个的底色(或有颜色变化),该怎么做?

解决方案 »

  1.   

    procedure TSearchanger_Form.StringGrid1DrawCell(Sender: TObject; ACol,
      ARow: Integer; Rect: TRect; State: TGridDrawState);
    begin
     with StringGrid1.Canvas do
        begin        
          tmp:=stringgrid1.Cells[ACol,ARow];
          StringGrid1.Canvas.Brush.Color:=clred;
          TextRect(Rect,ACol,ARow,StringGrid1.Cells[ACol,ARow]);
          DrawText(Handle, PChar(tmp),length(tmp),Rect, DT_CENTER); 
        end;end;
      

  2.   

    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      if (Acol = 1) and (ARow = 1) then
      begin
        StringGrid1.Canvas.Brush.Color := clRed;
        StringGrid1.Canvas.FillRect(Rect);
      end;end;
      

  3.   

    请问:我想在程序运行时,在stringgrid的cells中依次输入采来的数据,而该怎么做?采集数据写入 cells 太快!没有颜色变化的视觉效果的!另:如果 当采到当前的一格时,改变这个的底色(或有颜色变化),而此前 格子颜色恢复本色!这还要求你stringgrid的cells中写入数据是否是有序的。