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
|
void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if( (bool)StrToInt(StringGrid1->Cells[ ARow][ ACol])) StringGrid1->Cells[ ARow][ ACol]="0";
else StringGrid1->Cells[ ARow][ACol]="1";
Form1->Caption = StringGrid1->Cells[ ARow][ACol];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if( (bool)StrToInt(StringGrid1->Cells[ ARow][ ACol]))
StringGrid1->Canvas->Brush->Color = clRed;
else
StringGrid1->Canvas->Brush->Color = clBlue;
StringGrid1->Canvas->FillRect(Rect);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
for( int i = 0; i<StringGrid1->ColCount; i++)
for( int j = 0; j<StringGrid1->RowCount; j++)
StringGrid1->Cells[ i][ j] = "1";
} |