如何将Delphi中设计时修改自定义组件属性的方法改写成长尾?

2026-04-10 18:103阅读0评论SEO基础
  • 内容介绍
  • 相关推荐

本文共计297个文字,预计阅读时间需要2分钟。

如何将Delphi中设计时修改自定义组件属性的方法改写成长尾?

我正在编写一个简单的组件。我想要实现的是,我的MethodOptions能够根据Object Inspector中的方法I选择来更改。例如,目前为了阻止我编码:TmyMethod=(cmFirst, cmSecond); TmyMethodOptions=class(TPersiste);

如何将Delphi中设计时修改自定义组件属性的方法改写成长尾?

我正在编写简单的组件.我想要实现的是我的MethodOptions将根据方法I选择在Object Inspector中更改.

像这样的东西:

到目前为止我编码:

TmyMethod = (cmFirst, cmSecond); TmyMethodOptions = class(TPersistent) published property SomethingInBase: boolean; end; TmyMethodOptionsFirst = class(TmyMethodOptions) published property SomethingInFirst: boolean; end; TmyMethodOptionsSecond = class(TmyTMethodOptions) published property SomethingInSecond: boolean; end; TmyComponent = class(TComponent) private fMethod: TmyMethod; fMethodOptions: TmyMethodOptions; procedure ChangeMethod(const Value: TmyMethod); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property Method: TmyMethod read fMethod write ChangeMethod default cmFirst; property MethodOptions: TmyMethodOptions read fMethodOptions write fMethodOptions; end; implementation procedure TmyComponent.ChangeMethod(const Value: TmyMethod); begin fMethod := Value; fMethodOptions.Free; // case... if Value = cmFirst then fMethodOptions := TmyMethodOptionsFirst.Create else fMethodOptions := TmyMethodOptionsSecond.Create; // fMethodOptions.Update; end; constructor TmyComponent.Create(AOwner: TComponent); begin inherited; fMethodOptions := TmyMethodOptions.Create; fMethod := cmFirst; end; destructor TmyComponent.Destroy; begin fMethodOptions.Free; inherited; end;

当然它几乎没有任何东西(除了悬挂IDE),我没有任何起点可以搜索合适的知识来实现​​这一点.

如果我理解正确,我相信这是Developer Express在其Quantum Grid组件中实现的相同技术,用于动态显示网格中各种字段类型的不同属性.这里有机制的解释: Technology of the QuantumGrid

本文共计297个文字,预计阅读时间需要2分钟。

如何将Delphi中设计时修改自定义组件属性的方法改写成长尾?

我正在编写一个简单的组件。我想要实现的是,我的MethodOptions能够根据Object Inspector中的方法I选择来更改。例如,目前为了阻止我编码:TmyMethod=(cmFirst, cmSecond); TmyMethodOptions=class(TPersiste);

如何将Delphi中设计时修改自定义组件属性的方法改写成长尾?

我正在编写简单的组件.我想要实现的是我的MethodOptions将根据方法I选择在Object Inspector中更改.

像这样的东西:

到目前为止我编码:

TmyMethod = (cmFirst, cmSecond); TmyMethodOptions = class(TPersistent) published property SomethingInBase: boolean; end; TmyMethodOptionsFirst = class(TmyMethodOptions) published property SomethingInFirst: boolean; end; TmyMethodOptionsSecond = class(TmyTMethodOptions) published property SomethingInSecond: boolean; end; TmyComponent = class(TComponent) private fMethod: TmyMethod; fMethodOptions: TmyMethodOptions; procedure ChangeMethod(const Value: TmyMethod); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property Method: TmyMethod read fMethod write ChangeMethod default cmFirst; property MethodOptions: TmyMethodOptions read fMethodOptions write fMethodOptions; end; implementation procedure TmyComponent.ChangeMethod(const Value: TmyMethod); begin fMethod := Value; fMethodOptions.Free; // case... if Value = cmFirst then fMethodOptions := TmyMethodOptionsFirst.Create else fMethodOptions := TmyMethodOptionsSecond.Create; // fMethodOptions.Update; end; constructor TmyComponent.Create(AOwner: TComponent); begin inherited; fMethodOptions := TmyMethodOptions.Create; fMethod := cmFirst; end; destructor TmyComponent.Destroy; begin fMethodOptions.Free; inherited; end;

当然它几乎没有任何东西(除了悬挂IDE),我没有任何起点可以搜索合适的知识来实现​​这一点.

如果我理解正确,我相信这是Developer Express在其Quantum Grid组件中实现的相同技术,用于动态显示网格中各种字段类型的不同属性.这里有机制的解释: Technology of the QuantumGrid