J
jack2004
Unregistered / Unconfirmed
GUEST, unregistred user!
自定义控件中,DataSource和DataField1
unit REdit;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Db, DBCtrls;
type
TREdit = class(TEdit)
private
{ Private declarations }
FAllowChange: Boolean;
FDataLink: TFieldDataLink;
function GetDataField: string;
function GetDataSource: TDataSource;
procedure SetDataField(const Value: string);
procedure SetDataSource(Value: TDataSource);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(Aowner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property DataField1: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
end;
procedure Register;
implementation
//-------------------
uses DesignIntf, DBReg; <-----------提示找不到DBReg
//-------------------
constructor TREdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FDataLink:=TFieldDataLink.Create;
FAllowChange:=True;
end;
destructor TREdit.Destroy;
begin
FDataLink.OnDataChange:=nil;
FDataLink.Free;
inherited Destroy;
end;
function TREdit.GetDataField: string;
begin
Result:=FDataLink.FieldName;
end;
function TREdit.GetDataSource: TDataSource;
begin
Result:=FDataLink.DataSource;
end;
procedure TREdit.SetDataField(const Value: string);
begin
FDataLink.FieldName:=Value;
end;
procedure TREdit.SetDataSource(Value: TDataSource);
begin
FDataLink.DataSource:=Value;
end;
procedure Register;
begin
RegisterComponents('Astar', [TREdit]);
//------------------------------------
RegisterPropertyEditor(TypeInfo(string), TREdit, 'DataField1', TDataFieldProperty); <-------不要DBreg,提示找不到TDataFieldProperty
//------------------------------------
end;
end.
Delphi2005下如何解决??????
如果要两个以上的DataField,如何写???
unit REdit;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Db, DBCtrls;
type
TREdit = class(TEdit)
private
{ Private declarations }
FAllowChange: Boolean;
FDataLink: TFieldDataLink;
function GetDataField: string;
function GetDataSource: TDataSource;
procedure SetDataField(const Value: string);
procedure SetDataSource(Value: TDataSource);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(Aowner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property DataField1: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
end;
procedure Register;
implementation
//-------------------
uses DesignIntf, DBReg; <-----------提示找不到DBReg
//-------------------
constructor TREdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FDataLink:=TFieldDataLink.Create;
FAllowChange:=True;
end;
destructor TREdit.Destroy;
begin
FDataLink.OnDataChange:=nil;
FDataLink.Free;
inherited Destroy;
end;
function TREdit.GetDataField: string;
begin
Result:=FDataLink.FieldName;
end;
function TREdit.GetDataSource: TDataSource;
begin
Result:=FDataLink.DataSource;
end;
procedure TREdit.SetDataField(const Value: string);
begin
FDataLink.FieldName:=Value;
end;
procedure TREdit.SetDataSource(Value: TDataSource);
begin
FDataLink.DataSource:=Value;
end;
procedure Register;
begin
RegisterComponents('Astar', [TREdit]);
//------------------------------------
RegisterPropertyEditor(TypeInfo(string), TREdit, 'DataField1', TDataFieldProperty); <-------不要DBreg,提示找不到TDataFieldProperty
//------------------------------------
end;
end.
Delphi2005下如何解决??????
如果要两个以上的DataField,如何写???