例如一个button的名字叫button1,那么
str := button1.name;

解决方案 »

  1.   

    str := button1.name;
    (FindComponent(str) as TButton).Visible := False;
      

  2.   

    FindComponent(str) as TButton 是什么意思呢? 大哥多些
      

  3.   

    我替他说吧,看来周末忙。分我不要。TComponent中有一个方法叫FindComponent,就是根据名字找出相应的组件。TForm是从TComponent派生的,所以也能用,这里不写对象名表示是Form的方法中的代码。as TButton:FintComponent返回的类型是TComponent,用as TButton是把它转换成TButton的类型。不过他这是打个比方,你有可能是其它类型,如果是TEdit, 就用as TEdit好了,如果是TListBox就用as TListBox。当然,你可以从FindCompoent(控件名).ClassType知道它是什么类的实例。