troubleshooting Question

Delphi TClientDataSet - override Refresh event

Avatar of rafaelrasche
rafaelrasche asked on
ProgrammingDelphiPascal
4 Comments1 Solution1006 ViewsLast Modified:
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros