//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
StringGrid1->Cells[2][1] = "rojo";
StringGrid1->Cells[3][1] = "verde";
StringGrid1->Cells[2][2] = "celeste";
StringGrid1->Cells[2][3] = "Azul";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if ((ACol>0) && (ARow>0))
{
if (StringGrid1->Cells[ACol][ARow] == "rojo")
StringGrid1->Canvas->Brush->Color = clRed;
else if (StringGrid1->Cells[ACol][ARow] == "verde")
StringGrid1->Canvas->Brush->Color = clGreen;
else if (StringGrid1->Cells[ACol][ARow] == "celeste")
StringGrid1->Canvas->Brush->Color = clAqua;
else if (StringGrid1->Cells[ACol][ARow] == "Azul")
StringGrid1->Canvas->Brush->Color = clBlue;
else
StringGrid1->Canvas->Brush->Color = clBlack;
StringGrid1->Canvas->FillRect(Rect);
StringGrid1->Canvas->TextOut(Rect.Left,Rect.Top,StringGrid1->Cells[ACol][ARow]); }
}
//---------------------------------------------------------------------------