How to create fixed columns in a TDBGrid (Views: 100)


How do I freeze Column 1 in place on a DBGrid? I found a FixedCols property for a TCustomGrid, but there doesn't seem to be anything for a DBGrid.


If you put ...

TFixColDBGrid = class(TDBGrid)
  property FixedCols;

... in your interface type section. And this ...

TFixColDBGrid(DBGrid1).FixedCols := 2;

... in your FormCreate procedure, it will fix the first two columns (ie the indicator column and the first data column - if you have no indicator column, set it to 1).

This is quite a good trick for simply exposing an ancestors property, particularly for complicated visual descendants with many properties which are set at design time.

<< Back to main page