KOD cpp: UKRYJ
StringGrid1= new TStringGrid(Form6);
StringGrid1->Parent= Form6;
StringGrid1->FixedCols= 1;
StringGrid1->FixedRows= 1;
StringGrid1->Options << goEditing;
;
StringGrid1->Parent= Form6;
StringGrid1->FixedCols= 1;
StringGrid1->FixedRows= 1;
StringGrid1->Options << goEditing;
;
Chciałbym dostać się do metody
OnDrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State)
i wypełnić ją ciałem, tak jak w statycznym przypadku:
KOD cpp: UKRYJ
void __fastcall Form::StringGrid1DrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State)
{
if (State.Contains(gdFocused))
Label1->Caption= "Cell(" + IntToStr((ACol)) + "," + IntToStr((ARow)) + ")"+ " has the focus.";
if ((ACol >= 1 && ACol <= 2) && (ARow >= 1 && ARow <= 2)) // if Fonts in color.
StringGrid1->Canvas->Font->Color= clRed;
StringGrid1->Canvas->TextOut(Rect.Left, Rect.Top, StringGrid1->Cells[ACol][ARow]);
}
{
if (State.Contains(gdFocused))
Label1->Caption= "Cell(" + IntToStr((ACol)) + "," + IntToStr((ARow)) + ")"+ " has the focus.";
if ((ACol >= 1 && ACol <= 2) && (ARow >= 1 && ARow <= 2)) // if Fonts in color.
StringGrid1->Canvas->Font->Color= clRed;
StringGrid1->Canvas->TextOut(Rect.Left, Rect.Top, StringGrid1->Cells[ACol][ARow]);
}
Próbuję podpiąc funkcję funkcja: StringGrid1->OnDrawCell = funkcja,
a ciało funkcja zdefiniować jak wyżej, tzn.::
KOD cpp: UKRYJ
if (State.Contains(gdFocused))
Label1->Caption= "Cell(" + IntToStr((ACol)) + "," + IntToStr((ARow)) + ")"+ " has the focus.";
if ((ACol >= 1 && ACol <= 2) && (ARow >= 1 && ARow <= 2)) // if Fonts in color.
StringGrid1->Canvas->Font->Color= clRed;
StringGrid1->Canvas->TextOut(Rect.Left, Rect.Top, StringGrid1->Cells[ACol][ARow]);
Label1->Caption= "Cell(" + IntToStr((ACol)) + "," + IntToStr((ARow)) + ")"+ " has the focus.";
if ((ACol >= 1 && ACol <= 2) && (ARow >= 1 && ARow <= 2)) // if Fonts in color.
StringGrid1->Canvas->Font->Color= clRed;
StringGrid1->Canvas->TextOut(Rect.Left, Rect.Top, StringGrid1->Cells[ACol][ARow]);
Ale ciągle coś nie tak, mimo roznych kombinacji.
Więc jak? Jest sposób?