Board index » delphi » Setting DBGrid Column Color
richard plimmer
![]() Delphi Developer |
Setting DBGrid Column Color2003-11-11 04:59:47 AM delphi128 Hi, I have a grid connected to a dataset that has some read only columns. The number of columns in the dataset varies so they cannot be created in the grid at design time. I'd like to be able to cycle through the columns in the grid (after the dataset has been opened) and if the field a column is attached to is read only, make that column grey. I have tried using the following code but it doesn't seem to do anything: for i := 0 to Grid.Columns.Count - 1 do begin if Grid.Columns[i].ReadOnly then Grid.Columns[i].Color := clBtnFace else Grid.Columns[i].Color := clWindow; end; Is this because you cannot set the column color when the columns aren't persistant? Thanks in advance. Richard |