我从TListView派生,希望隐藏OnCustomDrawItem属性,于是将其设为protected,但是他还是在Events列表里为什么?怎么做才能隐藏他?

解决方案 »

  1.   

    父类的PUBLIC属性自动继承,这怎么隐藏啊??除非你不从TLISTVIEW继承;
      

  2.   

    或者可以这样,把OnCustomDrawItem声明为只读属性unit MyListView;interfaceuses
      Windows, Messages, SysUtils, Classes, Controls, ComCtrls;type
      TMyListView = class(TListView)
      private
        { Private declarations }
        FOnCustomDrawItem: TLVCustomDrawItemEvent;
      protected
        { Protected declarations }
      public
        { Public declarations }
      published
        { Published declarations }
        property OnCustomDrawItem: TLVCustomDrawItemEvent read FOnCustomDrawItem;
      end;procedure Register;implementationprocedure Register;
    begin
      RegisterComponents('GybCtrl', [TMyListView]);
    end;{ TMyListView }
    end.
      

  3.   

    是啊,父类的Pulished属性都是自动继承的。怎么做呢!
    关注!!!!
      

  4.   

    把父类的某一Published属性重新声明为只读或只写属性
    这一属性就不会在Object Inspector上出现
      

  5.   

    哦如果设为有没有什么办法将他只付一次值,就像const那样。我这样写,但是报错: property OnCustomDrawItem:TLVCustomDrawItemEvent read FOnCustomDrawItem default DrawColoredItem;[Error] AutoLV.pas(183): Field or method identifier expectedDrawColoredItem是自己的自画handler.
      

  6.   

    那就这样,加一Constructor
    constructor TMyListView.Create(AOwner: TComponent);
    begin
      inherited;
      inherited OnCustomDrawItem := DrawColoredItem;
    end;
      

  7.   

    好了好了!谢谢大家。不用再从TCistomListView派生了,写一大串property....