对于DBGrid,
//===========================================================
void __fastcall TF_TJMXJG::dgMXJGDrawColumnCell(TObject *Sender,
const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
{
//如果提示栏有值
if(dgMXJG->DataSource->DataSet->FieldByName("提示")->AsString != "")
{
dgMXJG->Canvas->Font->Color = clRed; //文字颜色
dgMXJG->Canvas->Brush->Color = clBlue;//背景色
};
dgMXJG->DefaultDrawColumnCell(Rect, DataCol, Column, State); //重画
}
ListItem
//===========================================================
void __fastcall TF_DRSJ:: LVTJRYCustomDrawItem(TCustomListView *Sender,
TListItem *Item, TCustomDrawState State, bool &DefaultDraw)
{
if(Item->SubItems->Strings[7] == "0")
Item->ListView->Canvas->Font->Color = clBlack;
else
{
if (Item->SubItems->Strings[7] == "R")//表示有重名的人员
Item->ListView->Canvas->Font->Color = clRed; //字体用红色
else
Item->ListView->Canvas->Font->Color = clBlue; //用蓝色
};
}