我用StringGrid显示一张列表,但怎么让显示出来的数据显示出不同的颜色,谢谢。

解决方案 »

  1.   

    在DBGrid的DrawDataCell事件中:
    with (sender as TDBGrid).Canvas do
    begin  if Table1.Fieldbyname(′Salary′).value<=SpinEdit1.value then   DBGrid1.Canvas.Brush.Color:=ColorGrid1.ForeGroundColor else  DBGrid1.Canvas.Brush.Color:=ColorGrid1.BackGroundColor; DBGrid1.Canvas.FillRect(Rect); DBGrid1.Canvas.TextOut(Rect.left+2,Rect.top+2,Field.AsString);end;
      

  2.   

    很感谢 flyinwuhan(超越) ,不过你没看懂我的题目,我要求的是字体,不是方格,所以要把
    DBGrid1.Canvas.Brush.Color
    改成
    DBGrid1.Canvas.Font.Color