Drawing an image in a cell of a Delphi DBGrid

Designed to enable a user to view and edit data in a tabular grid, the TDBGrid component provides various ways of customizing its appearance. With so flexible component, a Delphi developer can always find new ways to make data more attractive.
A picture is worth a thousand words
While adding colors to a DBGrid can produce some neat effects, if you really want to improve the visual representation of data in you applications, you might consider using images instead of the “boring” text.
Images in DBGrid
Let’s see how to paint an image in a cell of a TDBGrid.
Here’s how the OnDrawColumnCell event handler for the DBGrid1 component looks:


To “paint” the above DBGrid, I’ve used a TImageList (ImageList1) component (“Win32” component palette tab) to store some (dummy for this test) images. Three images are added, each used to reflect the value of an employees salary.