游子日月长

笑渐不闻声渐悄,多情却被无情恼!

导航

delphi 中判断对象是否具备某一属性

  Uses   TypInfo;  
   
  {$R   *.dfm}  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
  var  
      I:   Integer;  
  begin  
      for   I   :=   0   to   ComponentCount   -   1   do  
          if   IsPublishedProp(Components[I],   'Caption')   then  
              ListBox1.Items.Add(Components[I].Name);  

  end;  

posted on 2017-01-11 11:43  游子日月长  阅读(322)  评论(0编辑  收藏  举报