Description


It is triggered before the cell enters edit mode. Allows you to disable editing.


When editing a cell, the following chain of events is triggered: OnBeforeEdit > OnAplyEditText > OnEditAccept > OnAfterEdit


The parameters of this event contain the Accept parameter that allows you to prevent editing of a cell.




Example


procedure Form1_TableGrid1_OnBeforeEdit (Sender: TObject; ACol, ARow: Integer; var Accept: Boolean);
begin
   // Prevent editing columns 2 and 3 (numbering columns from 0)
   if (ACol = 3) and (ARow = 4) then Accept := False;


   // Cancel edit if you entered an empty value
   if Form1.TableGrid1.Cells[ACol, ARow] = '' then Accept := False;
end;