Delphi StringGrid同一个表格中,如何显示不同颜色的字,多谢啊~

解决方案 »

  1.   

    这个很多人问过了,给你个参考:http://topic.csdn.net/u/20081007/14/7f67a3c2-e2c1-40b9-842c-d7c5201be97f.html?seed=506909187
    http://topic.csdn.net/t/20040324/20/2882325.html
    ...
      

  2.   

    在Cell中自绘,事件是OnDrawColumnCell
      

  3.   

    在OnDrawCell事件中写下面 
    with stringgrid1 of
        Canvas.Font.Size:= CellFontBrush[ACol].Size; //字体大小
        Canvas.Font.Color:= CellFontBrush[ACol].Color; //字体颜色
        Canvas.Brush.color:=CellColorBrush[ACol];//颜色背景
        Canvas.FillRect(ARect);
        DrawText(Canvas.Handle,PChar(Cells[ACol,ARow]),Length(Cells[ACol,ARow]),ARect,1 or DT_SINGLELINE or 4); //文字居中
    end;
      

  4.   


    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      if ACol = 1 then
      begin
        StringGrid1.Canvas.Font.Color := clRed;
        StringGrid1.Canvas.TextOut(Rect.Left,Rect.Top,'A');
        StringGrid1.Canvas.Font.Color := clBlue;
        StringGrid1.Canvas.TextOut(Rect.Left+10,Rect.Top,'B');
        StringGrid1.Canvas.Font.Color := clGreen;
        StringGrid1.Canvas.TextOut(Rect.Left+20,Rect.Top,'C');
      end;
    end;