1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
void __fastcall TForm1::DBGrid1DrawColumnCell(TObject *Sender,
const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
{
TCanvas *pCanvas = ((TDBGrid *)Sender)->Canvas;
if ((Form1->DBGrid1->DataSource->DataSet->RecNo%2)==0) pCanvas->Brush->Color = clYellow;
if (Form1->DBGrid1->DataSource->DataSet->FieldByName("Rang")->Value == 2)
{
Form1->DBGrid1->Canvas->Brush->Color = clGreen;
}
if(State.Contains(odSelected)) //ligne selectionnée
{
pCanvas->Brush->Color = clRed;
pCanvas->FillRect(Rect);
pCanvas->Font->Color = clYellow;
if (Form1->DBGrid1->DataSource->DataSet->FieldByName("Rang")->Value == 2)
{
Form1->DBGrid1->Canvas->Font->Style = TFontStyles() << fsBold;
Form1->DBGrid1->Canvas->Font->Color = clRed;
}
}
else
{
if (Form1->DBGrid1->DataSource->DataSet->FieldByName("Rang")->Value == 2)
{
Form1->DBGrid1->Canvas->Font->Style = TFontStyles() << fsBold;
Form1->DBGrid1->Canvas->Font->Color = clRed;
}
pCanvas->FillRect(Rect); //Les autres lignes
}
Form1->DBGrid1->DefaultDrawColumnCell(Rect, 1, Column, State);
} |