请问:由TComponent派生的一个组件,(200分)

  • 主题发起人 主题发起人 jianguo_bu
  • 开始时间 开始时间
J

jianguo_bu

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样在这个组件里增加一个像TADODataSet的connection属性??
published
.
.
property Connection: TADOConnection read GetConnection write SetConnection;
.
.
end;

这样对吗?如果对,那这两个方法又怎样实现呢???
 
对!不过你提的问题都是超期问题,等有时间的富翁回答吧。
 
我的帐号怎么还不可以提问?
 
unit ComponentEx;

interface

uses
Windows, Messages, SysUtils, Classes, ADODB;

type
TComponentEx = class(TComponent)
private
{ Private declarations }
FConnection : TADOConnection;
function GetConnection : TADOConnection;
procedure SetConnection(const Value: TADOConnection);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
property Connection: TADOConnection read GetConnection write SetConnection;

end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Samples', [TComponentEx]);
end;

{ TComponentEx }

constructor TComponentEx.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FConnection := nil;
end;

function TComponentEx.GetConnection: TADOConnection;
begin
Result := FConnection;
end;

procedure TComponentEx.SetConnection(const Value: TADOConnection);
begin
if FConnection <> Value then
begin
FConnection := Value;
end;
end;

end.
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
I
回复
0
查看
772
import
I
I
回复
0
查看
653
import
I
后退
顶部