Disabling columns in grid[solution]

I have at last found how to achieve the effect I wanted regarding "disabling"
grid cells at run time. I didn't get any responses to my earlier postings so
either you're all dumber than I am or I'm so dumb nobody deigned to inform me
of the obvious answer. The solution was found in the FAQ on ftp.borland.com -
will wonders never cease! Any way for anybody who mave have a similar problem,
here's the solution.

Kym Wilson

The event which is triggered when a new row is selected in a grid is the
ONDATACHANGE event for the corresponding datasource. In the ONDATACHANGE event
you first test for the dsbrowse state.

Hence I insert code into both the grid's ONCOLUMNENTER event (to
catch lateral movement on a row) and the data sources ONDATACHANGE event (to
catch vertical movement). A mouse click on a cell in a different row and
column will trigger both events.

procedure Ttfdepth.DataSource1DataChange(Sender: TObject; Field: TField);
  if (Sender as TDataSource).State = dsBrowse then
    if dbgrid1.selectedindex>0 then  {This ensures selectfield.name is valid}

procedure Ttfdepth.dbgrid1colenter(Sender: TObject);
  with dbgrid1.selectedfield do
    if table1rel.value then
        if (name='Table1DEPTH')

          {move to next cell on right}

        if (name='Table1OFFSET') or (name='Table1REF') then

          {move to next cell on left}


There is a slight problem with this in that moving cells with the mouse
triggers the the ONCOLENTER event before the ONDATACHAGE event, so that moving
from a row in which eg depth is disabled to the depth cell in a row in which
it is enabled will still cause the cursor to skip, since the table1rel value is
still set to the originating row at the time of the ONCOLEVENT. A second click
of the mouse will succesfully position the cursor since at that time it is a
move along the new row and the new table1rel value is used.