AdvStringGrid RowChanging event

Good afternoon to all,

   j have little problem with this event.



what j do is avoid row changing if the new row is the last one who j leave blank (no data).

To do that j use this code (where SG2 is TAdvStringGrid)



procedure TMF.SG2RowChanging(Sender: TObject; OldRow, NewRow: Integer;

var Allow: Boolean);

begin

   if NewRow = SG2.RowCount - 1 then Allow:=False;

end;



This code work well, infact if j press the arrow down key and new next row is the last one, nothing append.



But if j change the row position by mouse click, the row does not change but the NewRow will be draw with the select color.



It is only a cosmetic problem ...



Good evening



Daniele

I cannot reproduce this with the latest version of the grid.

With a default grid on the form and the code:


procedure TForm1.AdvStringGrid1RowChanging(Sender: TObject; OldRow,
  NewRow: Integer; var Allow: Boolean);
begin
  if NewRow = advstringgrid1.RowCount - 1 then Allow:=False;
  listbox1.Items.Add(inttostr(newrow));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  advstringgrid1.LinearFill(false);
  advstringgrid1.Options := advstringgrid1.Options + [goRowSelect];
end;

this doesn't allow to select the last row, not with mouse and not with keyboard.

Hi Bruno,

j do some tries .... and seems that the problem appears when the option RowSelect is selected (settet to true).



Can you try this ??



Thank's Bruno



Have a good nigth



Ciao



Daniele

As you can see in my sample code, I had enabled RowSelect:


procedure TForm1.FormCreate(Sender: TObject);
begin
  advstringgrid1.LinearFill(false);
  advstringgrid1.Options := advstringgrid1.Options + [goRowSelect];
end;