DBGrid简单自绘(字体颜色、背景等)

void __fastcall TForm1::DBGrid1DrawColumnCell(TObject *Sender,
      const TRect &Rect, int DataCol, TColumn *Column,
      TGridDrawState State)
{
    AnsiString name= Column->Field->DataSet->FieldByName("NAME")->AsString;
    if(name=="功能科室"&&DataCol==1) //只绘制name为功能科室行和第二列的交集
        DBGrid1->Canvas->Font->Color=clRed;
    if(name=="心电图室")
        DBGrid1->Canvas->Font->Color=clGreen;
    if(name=="胃镜室")
        DBGrid1->Canvas->Brush->Color=clGreen;
    DBGrid1->DefaultDrawColumnCell(Rect,DataCol,Column,State);//是什么意思??
}

 

 

dbgrid

posted @ 2011-08-25 14:14  瓜蛋  阅读(946)  评论(0编辑  收藏  举报