When you place a dbgrid on your form, it creates 2 rows by default (a title row which is fixed and a normal row which is not fixed) My question is if there is a way to remove this 2nd normal row at runtime (leaving only the fixed title row) unless there is actually data to populate the row and in that case it should be shown of course.
For example, if I run a query that returns 0 results when my form is created, I would like only to show the title row, but if the query returns a result show the title row and all the rows that contain data like normal.
Any help would be appreciated.
No, this is not possible. You can see this yourself by dropping a TDBGrid on a new form, and not attaching any datasource to it. It always has at least one data row, even if there is no data to populate it, and at least one column. (It makes sense that this isn't possible; it is, after all, a grid.)
The closest you can get is to remove dgColLines
and dgRowLines
from the TDBGrid.Options
, which still leaves you with a data row, but it's just not clearly visible.