There is a BUG(AccessViolation error) with this component.
It happens only if the selected row of the grid is at the last record of the dataset
Here is a simple source that demonstrates the AV :
unit Unit9;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvUtil, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.UI.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async,
FireDAC.Phys, FireDAC.Phys.FB, FireDAC.Phys.FBDef, FireDAC.VCLUI.Wait, FireDAC.DApt, FireDAC.Comp.Client, Data.DB, FireDAC.Comp.DataSet, Vcl.Grids, AdvObj, BaseGrid, AdvGrid, DBAdvGrid, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm9 = class(TForm)
DBAdvGrid1: TDBAdvGrid;
DataSource1: TDataSource;
FDMemTable1: TFDMemTable;
FDConnection1: TFDConnection;
FDQuery1: TFDQuery;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
FDTable1: TFDTable;
Label1: TLabel;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
FilterID:Integer;
public
{ Public declarations }
end;
var
Form9: TForm9;
implementation
{$R *.dfm}
procedure TForm9.Button1Click(Sender: TObject);
begin
FDConnection1.Connected:=True;
FDQuery1.Open();
FilterID:=1;
end;
procedure TForm9.Button2Click(Sender: TObject);
Var IC:Integer;
begin
FDTAble1.DisableControls;
if Not FDTable1.Active Then FDTable1.Open();
FDTable1.Filtered:=False;
// Change the filter according to your table fields, it does not matter
Case FilterID of
1:Begin FDTAble1.Filter:='(GOdina=2025)And(Period=5)And(Vid='+FilterID.ToString+')'; FilterID:=2; End;
2:Begin FDTAble1.Filter:='(GOdina=2025)And(Period=5)And(Vid='+FilterID.ToString+')'; FilterID:=1; End;
End;
FDTable1.filtered:=true;
DBAdvGrid1.Columns.Clear;
With DBAdvGrid1.Columns.Add do width:=15;
For Ic:=0 to FDTable1.FieldCount-1 Do
With DBAdvGrid1.Columns.Add do
Begin
FieldName:= FDTable1.Fields[ic].FieldName;
Field:=FDTable1.Fields[Ic];
End;
FDTable1.EnableControls;
Label1.Caption:='Record count: '+FDTable1.RecordCount.ToString;
Case CheckBox1.Checked of
True:DBAdvGrid1.Row:=FDTable1.RecordCount; // This way you hit the AV
False:DBAdvGrid1.Row:=1; // This way everything is fine
End;
end;
end.