26-05-2020, 06:26 PM
لأنه الحدث المسؤول عن رسم الخلايا في المكون, الحدث تقريبا في مناداة دائمة كل ضغطة بالفارة او انتقال من خلية الى خلية اخرى يتم استدعاء الحدث OnDrawCell, لا يمكن التلوين من خلال دالة خارجية لان فيه شغل كبير فستحتاج للتلوين كل ما تعاملت مع stringgrid.
PHP كود :
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
// Title cells
if gdFixed in State then
begin
StringGrid1.Canvas.Brush.Color := clActiveCaption;
StringGrid1.Canvas.Font.Color := clBlack;
end
else if gdSelected in State then // selected cells
begin
StringGrid1.Canvas.Brush.Color := clWebLightBlue;
StringGrid1.Canvas.Font.Color := clBlack;
end
else
begin // cell normal state
StringGrid1.Canvas.Brush.Color := clInfoBk;
StringGrid1.Canvas.Font.Color := clBlack;
end;
Rect.Left := Rect.Left - 4;
StringGrid1.Canvas.FillRect(Rect);
StringGrid1.Canvas.TextOut(Rect.Left + 3, Rect.Top + 5, StringGrid1.Cells[ACol, ARow]);
end;

