用两个继承类,如下:
TEditA=Class(Tedit);
private
  FA:string;
...
published 
  property A:string read FA write FA;
...TEditB=Class(Tedit);
private
  FB:string;
...
published 
  property B:string read FB write FB;
...组合一个新的类
TEditC=Class(TCustomControl)
private
  TA:TEditA;
  TB:TeditB;  
Public 
  Constructor Create(AOWner:Tcomponent);override;
...constructor TEditC.Create(AOWner: Tcomponent);
begin
  inherited;
  TA:=TEditA.Create(Self);
  TA.Width:=50;
  TA.Height:=27;
  TA.Top:=0;
  TA.Visible:=true;
  TA.Parent:=Self;
  TA.Anchors:=[akTop, akLeft, akRight, akBottom];
  TA.Left:=0;
  TA.ReadOnly:=True;  TB:=TEditB.Create(Self);
  TB.Width:=50;
  TB.Height:=27;
  TB.Top:=0;
  TB.Visible:=true;
  TB.Parent:=Self;
  TB.Anchors:=[akTop, akLeft, akRight, akBottom];
  TB.Left:=TA.Width;
  
  Self.Width:=TA.Height+TB.Height;
  Self.Height:=27;
End;请问:TEditC中如何继承TEditA中FA和TEditB中FB属性(显示在控件的属性栏中)
      (除了再TEditC中重复定义外)

解决方案 »

  1.   

    加两个属性阿
    property a read Ta ;
    property b read tb;就通过Self.a.a和self.b.b来访问了
      

  2.   

    按照VCL常用的方法,你应该把TEditA和TEditB这两个类作为属性,从而间接的访问这两个类自己的属性。而不是把这两个类的属性再作为新类的属性,比如我们常见的Items属性一样。
      

  3.   

    楼上两位正解:
    property a read Ta write SetA;
    property b read tb write SetB;SetA(value:a)
    begin  a.assign(value); end;SetA(value:b)
    begin  b.assign(value); end;
    \这样你在对象察看器中就可以看到这两个对象的属性了。
      

  4.   

    楼上的建议不是等于在TEditC中重复定义TEditA和TEditB中的属性吗?等于没说,我的意思是由没又其他更好的方法!
      

  5.   

    呵呵,我觉得楼主一条道走到黑,别人给你之路也要被你骂,不知道csdn有没有黑名单功能