Grid Row changing

Good afternoon,

set an AdvStringGrid as default with this modifications

- ActiveRowColor to any color

- ActiveRowShow to True

- In Options goEditing to True



and



procedure TForm.SG1RowChanging(Sender: TObject; OldRow, NewRow: Integer;

var Allow: Boolean);

begin

SG1.RowFontColor[OldRow]:=clBlack;

SG1.RowFontColor[NewRow]:=clYellow;

Allow:=True;

end;



where SG1 is TAdvStringGrid



When move the cursor with the arrow key up/down all works as expetted (Old/NewRow change the font color).

But if i move the cursor (change the row) with mouse (for example from row 1 to row 5) what's happend is that rowchanging event is fired (ok) but for some reason (may be i forgot some settings) the OldRow remain "selected" with it's own font and row selected color and the NewRow change the font color (according to onrowchanging event).



I miss something??



Thank's



Daniele

Good morning to all,

   little update ...

In order to change data in ONLY one column, i use these preocedures



This one to allow edit in all cells but only in column 3

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

var CanEdit: Boolean);

begin

CanEdit:=False;

if Arow>0 then

begin

    if ACol=3 then CanEdit:=True;

end;

end;



This one to avoid cell changing and stay always in column 3

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

NewCol: Integer; var Allow: Boolean);

begin

if NewCol<>3 then Allow:=False;

end;



with any configuration (ActiveCellShow True/False, ActiveRowShow True/False) what append is, only with mouse, that i change the row and i click on any cells in column 3 the active cell change the position and i can edit it.

But if i click in any other cell but in different column the active cell does not change (as for CellChanging that avoid it).

I try to use

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

NewCol: Integer; var Allow: Boolean);

begin

if NewCol<>3 then

begin

      SG1.Col:=3; // Force column

      Allow:=False;

end;

end;



Without any result



Thank's for all



Daniele

Did you try to set grid.Col from the grid.OnClickCell event?

Good morning Bruno,

what i try to get is impossibile due to circumstance.

I need to edit only in one column (3) and i do it without problem, the problem (if is it) is the columns number or, better, the columns width.

Two case

1 - If the columns width is <= grid's width, i can change row staing in col 3

2 - if the columns width > grid's width is impossible stay in col 3 because to see the cell value is necessary scroll the grid. In this case is possible edit only in col 3.



Thank's for all



Regards



Daniele

I'm sorry but it is hard for me to understand from this description.
A sample source project with this issue isolated would help a lot to understand it.
You mention "if columns width ..." , are you referring to the width of column 3, the only editable column here or any other column? or?