I tried to do this:
void __fastcall TTetrisGame::DrawGrid1DrawCell(TObject *Sender, int ACol, int ARow,
TRect &Rect, TGridDrawState State)
{
this->Canvas->Brush->Color=clBlue;
this->Canvas->FillRect(Rect);
}
But it is a really weird result. I put my StringGrid in the middle of the window but I can't see any Blue color. Instead, it is transparent. I see a colored blue Grid in the right top corner of my window.
What am I doing wrong?
How can I color each cell individually?
You are painting on the wrong
Canvas.Inside your
OnDrawCellevent handler,thisrefers to the parent Form, because the handler is a member of theTTetrisGameclass. As such, you are painting on the Form'sCanvas. You need to paint on the Grid'sCanvasinstead: