{问题使者样的我想重写tadoquery控件相关事件,例如AfterOpen,AfterClose相关事件
由于我所用到的TadoQuery控件在打开和关闭时都调用需要调用同一个函数,所以想重新封装一下
TAdoQuery控件
我的简单代码
如下:}
unit YHCADOQuery;
interface
uses
SysUtils, Classes, DB, ADODB;
type
TYHCADOQuery = class(TADOQuery)
private
{ Private declarations }
sDefaultWhere: String;
sOrderBy: String;
sViewName: String;
function GetDefaultWhere: String;
procedure SetDefaultWhere(const Value: String);
function GetOrderBy: String;
procedure SetOrderBy(const Value: String);
function GetViewName: String;
procedure SetViewName(const Value: String);
procedure AfterOpen(DataSet: TDataSet);
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations}
//自己增加几个自定义属性
property ViewName: String read GetViewName write SetViewName;
property DefaultWhere: String read GetDefaultWhere write SetDefaultWhere;
property OrderBy: String read GetOrderBy write SetOrderBy;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents( "RedSuper ", [TYHCADOQuery]);
end;
function TYHCADOQuery.GetDefaultWhere: String;
begin
Result := sDefaultWhere;
end;
procedure TYHCADOQuery.SetDefaultWhere(const Value: String);
begin
sDefaultWhere := Value;
end;
function TYHCADOQuery.GetOrderBy: String;
begin
Result := sOrderBy;
end;
procedure TYHCADOQuery.SetOrderBy(const Value: String);
begin
sOrderBy := Value;
end;
function TYHCADOQuery.GetViewName: String;
begin
Result := sViewName;
end;
procedure TYHCADOQuery.SetViewName(const Value: String);
begin
sViewName := Value;
end;
procedure TYHCADOQuery.AfterOpen(DataSet: TDataSet);
begin
//但是事件不知道怎么写了,请教大侠帮忙。
inherited;
end;
end.