la solucion la encontre en
http://www.experts-exchange.com/Prog..._21354684.html
by: DissasterPosted on 2005-03-17 at 09:05:54ID: 13566959
I've encontered this error before, when I executed the dataset.enable/disablecontrols with a linked grid, and between this lines I deleted some records. As far as I understand this happens because the grid does not check how many records it has after it's been re-activated.
As far as I know this is a bug that delphi has from some time, I searched all over the internet for a long time before I found the solution, and this is it:
1.- copy the file dbgrids.pas to your proyect directory (the original location is in %Program files%\Borland\Delphi7\Source\Vcl)
this is to avoid re-compiling the vcl, which by the way i don´t know how to do, if someone know, i'll be glad if they tell me how.
2.- edit the dbgrids.pas file you just copied and make the TCustomDBGrid.UpdateActive procedure look like the following lines:
Código Delphi
[-]
procedure TCustomDBGrid.UpdateActive;
var
NewRow: Integer;
Field: TField;
begin
if FDatalink.Active and HandleAllocated and not (csLoading in ComponentState) then
begin
NewRow := FDatalink.ActiveRecord + FTitleOffset;
if (Row <> NewRow) and (NewRow < RowCount) then begin
if not (dgAlwaysShowEditor in Options) then HideEditor;
MoveColRow(Col, NewRow, False, False);
InvalidateEditor;
end;
Field := SelectedField;
if Assigned(Field) and (Field.Text <> FEditText) then
InvalidateEditor;
end;
end;
that's it.. now when you recompile your proyect, it will use this unit instead of the original dbgrids.pas, and the problem will be solved.
Hope this helps