Search code examples
delphidbgrid

Modify DBGrid cell content before it is displayed


I want to modify the content of a particular cell in dbgrid control when the database is loaded. For example, lets say I don't want any field of database to be displayed in dbgrid if it is equal to "forbidden". Is there any way that I can do that?


Solution

  • you can use the DataSetNotifyEvent Afteropen

    DBGrid.Datasource.Dataset.Afteropen :=

    and you can hide fields with:

    if Condition then DBGrid.columns[x].visible := false

    alternative you can check the condition on the OnDrawColumnCell event in order to overrite / delete some content in a specific cell