AdvStringGrid goRowSelect problem

Good morning to all,

i have a little problem with gorowselect and cell changing.

Normally i have a grid with gorowselect setted, but if i change column and i click on column 2 i need to edit this cell (if the row>0).

In the same way if i chance the cell and (for any reason with cursor key or mouse) i change the columns ant it return to 1 or 0, i need to reset the goroselect to true and show the full line on the row.

To do this i use the code posted below, but (if you can reproduce it) it does not work becouse if i change the column (return to 1) with key or mouse the grid optino does not change.

When i change the cell, the event chain seem to be

1) caneditcell

2) CellChanging

3) caneditcell

but for a strange reason, from 2 to 3 the grid.col does not change to a new value.



Can you check ?



procedure TFCP.SG1CanEditCell(Sender: TObject; ARow, ACol: Integer;

var CanEdit: Boolean);

begin

if (ACol=2) and (ARow>0) then

begin

    if (goRowSelect in SG1.Options)then SG1.Options:=SG1.Options - [goRowSelect] + [goEditing];

    CanEdit:=True;

end;

end;



procedure TFCP.SG1CellChanging(Sender: TObject; OldRow, OldCol, NewRow,

NewCol: Integer; var Allow: Boolean);

begin

if (goRowSelect in SG1.Options) then Exit;

if (NewCol=0) or (NewCol=1) then

begin

    SG1.Options:=SG1.Options + [goRowSelect] - [goEditing];

    Allow:=True;

end;

end;



Thank's in advance



Regard



Daniele

The grid is not really designed to toggle between row selection and single cell selection (needed for cell editing) this way, i.e. changing the goEditing & goRowSelect settings from these events.

If you need visibly a selected row, I'd suggest to set grid.ActiveRowShow = true. This will visually show the active row but will not perform a selection of multiple cells which hinders single cell selection for editing.
Using ActiveRowShow = true with goEditing = true and controling editing via OnCanEditCell and just return CanEdit with the desired value is as such a far simpler solution.