Using C++Builder, I have a TDBGrid with a column that I want to only output an icon to. I have the icon working, but it also outputs the value. How do I disable the value from being output by default?
Here's what I do right now via the OnDrawColumnCell event:
void __fastcall TMainForm::DBGrid1DrawColumnCell(TObject *Sender, const TRect &Rect,
int DataCol, TColumn *Column, TGridDrawState State)
{
if (DataCol==1) {
int iconindex=Column->Field->AsInteger;
ImageListSmall->Draw(reinterpret_cast<TDBGrid*>(Sender)->Canvas,Rect.Left+2,Rect.Top+2,iconindex,True);
}
}
You need to set the
TDBGrid::DefaultDrawingproperty to false (that does mean, however, that you will have to draw every cell, not just icon cells. You can use the publicTDBGrid::DefaultDrawColumnCell()method to draw your non-icon cells).The documentation for the
OnDrawColumnCellevent clearly says:And the documentation for the
DefaultDrawingproperty says: