Borland Delphi 7 has a control called the DBCtrlGrid. (Its counterpart in ASP.NET is the Repeater control).
In D7, at least, this control is rather limited. It will only allow a very limited range of other controls on its panels. Another rather harsh restriction is the programmer’s influence on the look per-panel: all controls on all panels must have the same look and setting properties (say, for one checkbox) in the repeater means setting that property for ALL controls in the Grid.
In a set of legacy applications I’m currently developing, a DBCtrlGrid is however the most light-weight and easily implemented solution.
One could extend the control, or purchase a commercial version, but as D7 is a legacy IDE for us, that’s not really an option.
A fortunate exception to the limitations above is the option to paint on each panel’s Canvas through the DBCtrlGrid’s PaintPanel event. Normally used to change the looks of the selected row, today I found a way to fake the visibility property of static controls, as least. It’s done through drawing images of those controls to the canvas. Using this work-around would be really bitter and ugly for anything other than images – but I’m in luck, as it’s images I want to toggle.
I want to toggle the visibility of three different images based on the presence of a character in a string field in my Query (Fields[6]) the DBCtrlGrid’s based on. Here’s the code:
procedure Form1.DBCtrlGrid1PaintPanel(DBCtrlGrid: TDBCtrlGrid; Index: Integer);
begin
if StrUtils.AnsiContainsStr(ADOQuery1.Fields.Fields[6].AsString, 'K') then DBCtrlGrid1.Canvas.Draw(804,6,imageK_template.Picture.Graphic);
if StrUtils.AnsiContainsStr(ADOQuery1.Fields.Fields[6].AsString, 'A') then DBCtrlGrid1.Canvas.Draw(804,15,imageA_template.Picture.Graphic);
if StrUtils.AnsiContainsStr(ADOQuery1.Fields.Fields[6].AsString, 'M') thenDBCtrlGrid1.Canvas.Draw(804,24,imageM_template.Picture.Graphic);
end;
I use AnsiContainsStr from StrUtils to check for the character. If I find it, I draw the graphic onto the canvas based on a (non-visible) picture I’ve placed on the form as well.
Note that I do not need to iterate over the query myself as the panel paint event steps through the rows itself, so I can just read the query value and it will automatically be the correct row.
The result (first row has KA in the string, the others just have A):

Part of this method was inspired by Eric Harmon’s book: “Delphi/Kylix Database Development” – one of the few sources anywhere about solid information (at least concerning DBCtrlGrid: I haven’t perused it further).