Avatar of rafaelrasche
rafaelrasche asked on

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

DelphiPascalProgramming

Avatar of undefined
Last Comment
rafaelrasche

8/22/2022 - Mon
Eddie Shipman

Override and don't call inherited. That's all there is to it.
atul_parmar

>>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.
ASKER CERTIFIED SOLUTION
Sinisa Vuk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
rafaelrasche

Thanks man!
That really did what I needed.
Your help has saved me hundreds of hours of internet surfing.
fblack61