Delphi TClientDataSet - override Refresh event

Hy

I Created a component derivated from TClientDataSet.

I'm having trouble to override the refresh event.
I need to "kill" the active event, and make I new one.

So, when the user is on the DBNavigator, and triggers the "Refresh" option, it should call the new method.

Here is the code for the component that I have today.
Could you help me to achieve this result?

Thanks.

unit ERPDataSet;

interface

uses
  System.SysUtils, System.Classes, Data.DB, Datasnap.DBClient;

type
  TERPDataSet = class(TClientDataSet)
  private
    { Private declarations }
    FNomeTabela: string;
    FChavePrimaria: string;
    FComandoSQL:string;
  protected
    { Protected declarations }
  public
    { Public declarations }
    procedure IncluiChavePrimaria;
  published
    { Published declarations }
    property ChavePrimaria:string read FChavePrimaria write FChavePrimaria;
    property ComandoSQL:string read FComandoSQL write FComandoSQL;
    property NomeTabela:string read FNomeTabela write FNomeTabela;
  end;

procedure Register;

implementation

//=================================================================================================================================================================================
procedure Register;
begin
  RegisterComponents('Rafael', [TERPDataSet]);
end;

{ TERPDataSet }

//=================================================================================================================================================================================
procedure TERPDataSet.IncluiChavePrimaria;
begin
  IndexDefs.Add('idx' + Name,ChavePrimaria,[ixPrimary,ixUnique]);
  IndexName:= 'idx' + Name;
  First;
end;

end.

Open in new window

rafaelrascheAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eddie ShipmanAll-around developerCommented:
Override and don't call inherited. That's all there is to it.
0
atul_parmarCommented:
>>So, when the user is on the DBNavigator, and triggers the "Refresh" option, it should call the new method.

In this case you will need to write your DBNavigator that calls your method.
0
Sinisa VukSoftware architectCommented:
Override InternalRefresh method of your new clientdataset:

TERPDataSet = class(TClientDataSet)
  private
..
  protected
...
  procedure InternalRefresh; override;
...
end;
....

procedure TERPDataSet.InternalRefresh;
begin
  if then ....
  else inherited InternalRefresh
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rafaelrascheAuthor Commented:
Thanks man!
That really did what I needed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.