DBGrid怎么重绘?
类似这样的效果,发现和stringgrid不一样.
[解决办法]
这是调整后的颜色,你改为自己喜欢的颜色就OK了
void __fastcall TForm1::DBGrid1DrawColumnCell(TObject *Sender, const TRect &Rect, int DataCol, TColumn *Column, TGridDrawState State){ class TMyGridBase : public TCustomGrid { public: __property Row; }; class TMyGrid : public TCustomDBGrid { public: __property DataLink; }; TMyGrid *MyGrid = (TMyGrid*)DBGrid1; TMyGridBase *MyGridBase = (TMyGridBase*)DBGrid1; TDBGrid *Grid = (TDBGrid*)Sender; if(MyGrid->DataLink->ActiveRecord == MyGridBase->Row-1) { //当前行 Grid->Canvas->Font->Color = clRed; Grid->Canvas->Brush->Color = clBlue; } else { Grid->Canvas->Font->Color = clBlack; Grid->Canvas->Brush->Color = clWhite; } DBGrid1->DefaultDrawColumnCell(Rect,DataCol,Column,State);}
[解决办法]