DrawGrid ใน Delphi นั้นจะไม่สามารถเข้าถึง Cell แต่ละ Cell ได้โดยตรง แต่จะใช้ Event OnDrawCell เป็นช่องทางในการใส่ข้อความหรือรูปภาพต่าง ๆ ลงในแต่ละ cell
ตัวอย่าง
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (ACol = 1) and (ARow = 2) then
DrawGrid1.Canvas.TextOut(Rect.Top + 2, Rect.Left + 2, 'TEXT');
end;
ไม่มีความเห็น