Sign in Join
Wiki copytemporary

TDrawGrid: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11**TDrawGrid** ![](/wiki-images/a/a7/Tdrawgrid.png) is a component on the [[Additional tab]] of the [[Component Palette]]. A DrawGrid provides a tabular display of graphical information. The developer is responsible for providing the code for drawing.
22
33Therefore, unlike other grid types, TDrawGrid requires implementing the following properties:
44
55- *OnDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState)*: Handler for the basic cell painting event
66- *DefaultDrawing*: a boolean property deciding whether or not *OnDrawCell* has to handle the entire code for cell painting or if the default drawing mechanism is fired in addition.
77
88The following simple example shows how to use *OnDrawCell*:
99
1010``` pascal
1111procedure TForm1.DrawGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
1212 aRect: TRect; aState: TGridDrawState);
1313var
1414 theCanvas: TCanvas;
1515begin
1616 theCanvas := TDrawGrid(Sender).Canvas;
1717 if odd(aRow) then
1818 begin
1919 if odd(aCol) then
2020 theCanvas.Brush.Color := clRed
2121 else
2222 theCanvas.Brush.Color := clGreen;
2323 end
2424 else
2525 begin
2626 if odd(aCol) then
2727 theCanvas.Brush.Color := clBlue
2828 else
2929 theCanvas.Brush.Color := clYellow;
3030 end;
3131 theCanvas.FillRect(aRect);
3232end;
3333```
3434
3535The demonstration code in this example fills the content of the cells with different colours, depending on whether the rows or columns are even or odd:
3636
37-<figure>
38-<img src="TDrawGridExample.png" title="TDrawGridExample.png" />
39-<figcaption>TDrawGridExample.png</figcaption>
40-</figure>
37+![](/wiki-images/e/e0/TDrawGridExample.png)
4138
4239## See also
4340
4441- [[TStringGrid]]
4542- [[TDBGrid]]
4643- [[Grids Reference Page]]
4744
4845---
4946*From the Free Pascal wiki, page "TDrawGrid", as it stood on 2023-04-05 after a change by Jwdietrich, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history