Delphi 如何使用RegisterPropertyEditor

Delphi 如何使用RegisterPropertyEditor,delphi,custom-component,Delphi,Custom Component,我创建了一个组件,该组件的(数据源)和(数据字段)属性与TDBLookupComboBox相同。 但现在我需要多个不同名称的(数据字段)属性。 我知道我应该使用RegisterPropertyEditor(),但我不知道如何使用? 这是我的密码 我该怎么办 TMyComp = class(TPanel) private { Private declarations } FDataSource:TDataSource; FDataField:String;

我创建了一个组件,该组件的(数据源)和(数据字段)属性与TDBLookupComboBox相同。 但现在我需要多个不同名称的(数据字段)属性。 我知道我应该使用RegisterPropertyEditor(),但我不知道如何使用? 这是我的密码 我该怎么办

  TMyComp = class(TPanel)
  private
    { Private declarations }
    FDataSource:TDataSource;
    FDataField:String;
    FDataField1:String;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Property DataSource: TDataSource Read FDataSource Write FDataSource;
    Property DataField: String Read FDataField Write FDataField;
    Property DataField1: String Read FDataField1 Write FDataField1;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TMyComp]);
  RegisterPropertyEditor(TypeInfo(string), ????, 'DataField1', ?????);
end;

首先,您需要将组件代码与注册代码分离,并将它们分别放在单独的运行时包和设计时包中,其中设计时包需要您的运行时包以及
dcldb
DesignIDE

然后,您可以这样编写代码:

运行时间:

unit MyRunTimeUnit;

interface

uses
  ...;

type
  TMyComp = class(TPanel)
  private
    { Private declarations }
    FDataSource: TDataSource;
    FDataField: String;
    FDataField1: String;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Property DataSource: TDataSource Read FDataSource Write FDataSource;
    Property DataField: String Read FDataField Write FDataField;
    Property DataField1: String Read FDataField1 Write FDataField1;
  end;

implementation

...

end.
设计时间:

unit MyDesigTimeUnit;

interface 

procedure Register;

implementation

uses
  DBReg, MyRunTimeUnit;

procedure Register;
begin
  RegisterComponents('Samples', [TMyComp]);
  RegisterPropertyEditor(TypeInfo(String), TMyComp, 'DataField1', TDataFieldProperty);
end;

然后,您可以将设计时软件包安装到IDE中。

首先,您需要将组件代码与注册代码分开,分别放在单独的运行时软件包和设计时软件包中,其中设计时软件包需要您的运行时软件包,
dcldb
DesignIDE
软件包

然后,您可以这样编写代码:

运行时间:

unit MyRunTimeUnit;

interface

uses
  ...;

type
  TMyComp = class(TPanel)
  private
    { Private declarations }
    FDataSource: TDataSource;
    FDataField: String;
    FDataField1: String;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Property DataSource: TDataSource Read FDataSource Write FDataSource;
    Property DataField: String Read FDataField Write FDataField;
    Property DataField1: String Read FDataField1 Write FDataField1;
  end;

implementation

...

end.
设计时间:

unit MyDesigTimeUnit;

interface 

procedure Register;

implementation

uses
  DBReg, MyRunTimeUnit;

procedure Register;
begin
  RegisterComponents('Samples', [TMyComp]);
  RegisterPropertyEditor(TypeInfo(String), TMyComp, 'DataField1', TDataFieldProperty);
end;

然后,您可以将设计时软件包安装到IDE中。

首先,您需要将组件代码与注册代码分开,分别放在单独的运行时软件包和设计时软件包中,其中设计时软件包需要您的运行时软件包,
dcldb
DesignIDE
软件包

然后,您可以这样编写代码:

运行时间:

unit MyRunTimeUnit;

interface

uses
  ...;

type
  TMyComp = class(TPanel)
  private
    { Private declarations }
    FDataSource: TDataSource;
    FDataField: String;
    FDataField1: String;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Property DataSource: TDataSource Read FDataSource Write FDataSource;
    Property DataField: String Read FDataField Write FDataField;
    Property DataField1: String Read FDataField1 Write FDataField1;
  end;

implementation

...

end.
设计时间:

unit MyDesigTimeUnit;

interface 

procedure Register;

implementation

uses
  DBReg, MyRunTimeUnit;

procedure Register;
begin
  RegisterComponents('Samples', [TMyComp]);
  RegisterPropertyEditor(TypeInfo(String), TMyComp, 'DataField1', TDataFieldProperty);
end;

然后,您可以将设计时软件包安装到IDE中。

首先,您需要将组件代码与注册代码分开,分别放在单独的运行时软件包和设计时软件包中,其中设计时软件包需要您的运行时软件包,
dcldb
DesignIDE
软件包

然后,您可以这样编写代码:

运行时间:

unit MyRunTimeUnit;

interface

uses
  ...;

type
  TMyComp = class(TPanel)
  private
    { Private declarations }
    FDataSource: TDataSource;
    FDataField: String;
    FDataField1: String;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Property DataSource: TDataSource Read FDataSource Write FDataSource;
    Property DataField: String Read FDataField Write FDataField;
    Property DataField1: String Read FDataField1 Write FDataField1;
  end;

implementation

...

end.
设计时间:

unit MyDesigTimeUnit;

interface 

procedure Register;

implementation

uses
  DBReg, MyRunTimeUnit;

procedure Register;
begin
  RegisterComponents('Samples', [TMyComp]);
  RegisterPropertyEditor(TypeInfo(String), TMyComp, 'DataField1', TDataFieldProperty);
end;
然后可以将设计时软件包安装到IDE中