Clicking Cell After Clicking Inactive Cell

I have a stringgrid with Mouseactions.DirectEdit := True and Options.goediting := True. With these settings, the effect of clicking a cell is to have a blinking cursor and the cell is in edit mode. However, this does not happen if you a cell that has canedit := false and then click a cell that has canedit := true. In this case, the editable cell has a selection rectangle and must be clicked a second time, despite the Mouseactions.DirectEdit := True. Shouldn't the editable cell be directly edited rather than requiring a second click?


To reproduce:
Drop a grid on a form.
Mouseactions.DirectEdit := True 
Options.goediting := True.
Create an OnCanEditCell handler containing:  if Acol = 2 then   Canedit:= False;

Run the program.
Click col 2, row 1
Click col 1, row 1: Result: Selection rectangle, cell is not in edit mode<---Not the expected result
Click col 1, Row 1:Result: cell is in edit mode
Click col1, row 2: Result : cell is in edit mode<---Expected result

Is this a bug? If this is the designed behavior, can you suggest a workaround so that directedit works regardless of whether the previous cell was editable?

Please change your code to:

procedure TForm1.AdvStringGrid1CanEditCell(Sender: TObject; ARow, ACol: Integer;
  var CanEdit: Boolean);
begin
  Canedit := (ACol <> 2);
end;

Thank you -- that solves it. My original example is a nice illustration of the negative consequences of sloppy programming (on my part).