You are hereFocussed cell and tstatfile
Focussed cell and tstatfile

Tdbwidgetgrid.statfile store last row and column and next focusing cell when load from tstatfile.
col=x
row=y
If tdbwidgetgrid.dataset is activated before read tstatfile of this tdbwidgetgrid, focused cell with row and column from tstatfile is OK. But If tdbwidgetgrid.dataset is activated after form loaded (focusing cell done before dataset activated), always got error message like this :
Operation cannot be performed on an inactive dataset
An exception occurred at $004DD38B :
EDatabaseError : Operation cannot be performed on an inactive dataset
$004DD38B DATABASEERROR, line 1954 of
C:/FPC/fixes_2_2/packages/fcl-db/src/base/db.pas
$004DEE71 TDATASET__CHECKACTIVE, line 160 of
C:/FPC/fixes_2_2/packages/fcl-db/src/base/dataset.inc
$004E14AA TDATASET__CHECKBROWSEMODE, line 1398 of
C:/FPC/fixes_2_2/packages/fcl-db/src/base/dataset.inc
$00504887 TGRIDDATALINK__FOCUSCELL, line 6626 of
C:/MSEGUI/lib/common/db/msedbedit.pas
$00505DA3 TCUSTOMDBWIDGETGRID__FOCUSCELL, line 7138 of
C:/MSEGUI/lib/common/db/msedbedit.pas
$0051CEF0 TCUSTOMGRID__DOSTATREAD, line 7860 of
C:/MSEGUI/lib/common/widgets/msegrids.pas
$00435D4C TSTATREADER__READSTAT, line 820 of
C:/MSEGUI/lib/common/kernel/msestat.pas
$004B9395 TSTATFILE__DOLINKSTATREAD, line 248 of
C:/MSEGUI/lib/common/kernel/msestatfile.pas
$00470A6C TOBJECTLINKER__FORALL, line 2356 of
C:/MSEGUI/lib/common/kernel/mseclasses.pas
$004B96D0 TSTATFILE__READSTAT, line 296 of
C:/MSEGUI/lib/common/kernel/msestatfile.pas
$00431531 TCUSTOMMSEFORM__DOAFTERLOAD, line 704 of
C:/MSEGUI/lib/common/widgets/mseforms.pas
$0043109E TCUSTOMMSEFORM__CREATE, line 642 of
C:/MSEGUI/lib/common/widgets/mseforms.pas
$00433864 TCUSTOMDOCKFORM__CREATE, line 1579 of
C:/MSEGUI/lib/common/widgets/mseforms.pas
$00433FA6 TDOCKFORM__CREATE, line 1756 of
C:/MSEGUI/lib/common/widgets/mseforms.pas
$00431171 TCUSTOMMSEFORM__CREATE, line 651 of
C:/MSEGUI/lib/common/widgets/mseforms.pas
$0046EFF3 CREATEMODULE, line 1329 of
C:/MSEGUI/lib/common/kernel/mseclasses.pas
$0042E75D TGUIAPPLICATION__CREATEFORM, line 14347 of
C:/MSEGUI/lib/common/kernel/msegui.pas
I think before focusing cell from tstatfile, it should check dataset is active or not.
I add
if not ds1.active then exit;
in msedbedit.pas and the error doesn't appear again.
procedure tgriddatalink.focuscell(var cell: gridcoordty);
var
int1,int2,int3,int4: integer;
ds1: tdataset;
begin
if (cell.row >= 0) and (cell.row <> fgrid.row) then begin
ds1:= dataset;
if not ds1.active then exit;===================================>
if (ds1 <> nil) then begin
int1:= rowtorecnonullbased(cell.row);
if not (finserting and not finsertingbefore) then begin
int3:= recnonullbased;
if (ds1.state <> dsfilter) and not fautoinserting and
(tcustomgrid1(fgrid).fnocheckvalue = 0) then begin
ds1.checkbrowsemode;
Thanks


I think tstatfile should not be used to save the focusedcell in a dbgrid, it works in the first rows only, disable t*grid.options og_savestate (default disabled for tdb*grid).
I disabled og_savestate, but in file of tstatfile, I see :
col=-1073741823
row=1
rowheight=20
www.acosys.co.id
Can not reproduce.
"
procedure tcustomgrid.dostatread(const reader: tstatreader);
var
po1: gridcoordty;
begin
fpropcolwidthref:= reader.readinteger('propcolwidthref',fpropcolwidthref,0);
fdatacols.dostatread(reader);
if og_savestate in foptionsgrid then begin
po1.col:= reader.readinteger('col',ffocusedcell.col);
po1.row:= reader.readinteger('row',ffocusedcell.row);
if og_rowsizing in foptionsgrid then begin
datarowheight:= reader.readinteger('rowheight',datarowheight);
end;
focuscell(po1);
end;
end;
"
Here is simple test project
www.acosys.co.id
Upps! Sorry! In my attachement project I use savestate, and in my real project I set optiosgrid with code.
BTW, what for og_savestate?
Thanks
www.acosys.co.id
og_savestate stores focused cell and rowheight (if user adjustable) into tstatfile. I'll change it to not store the focused row for dbgrids.
> I'll change it to not store the focused row for dbgrids.
Done, Trunk 3084.
Thanks
www.acosys.co.id