unit Unit1
interface
  uses windows,Messages,sysUtils;
type
  Ttest=class(|TForm)
  btn1:TButton;
  procedure DeleteByFor;
end;Implementation
{$r *.dfm}
 procedure vx;
 begin
   self.btn1.Caption:='ttt';//自定义的方法为什么不能识别窗体上的控件呢??   end;

解决方案 »

  1.   

    当然不能识别,因为你的vx方法不是Ttest的成员,改成这样就行了:
    unit Unit1
    interface
      uses windows,Messages,sysUtils;
    type
      Ttest=class(TForm)
      btn1:TButton;
      private
        procedure DeleteByFor;
        procedure vx;
      end;
    end;Implementation
    {$r *.dfm}
     procedure Ttest.vx;
     begin
       self.btn1.Caption:='ttt';//自定义的方法为什么不能识别窗体上的控件呢??   end;
      

  2.   

    楼主代码里还少引用 了  StdCtrls ,少了这个文件,肯定识别不了uses windows,Messages,sysUtils,StdCtrls;
      

  3.   

    type
      Ttest=class(|TForm)
      btn1:TButton;
      procedure DeleteByFor;放错位置了
    end;
      

  4.   

    procedure vx;
     begin
       self.btn1.Caption:='ttt';//自定义的方法为什么不能识别窗体上的控件呢??   end;
     全局的方法调用的时候不会传递self这个参数,而在对象里面则隐含传递了self,所以你这里调用self有问题,要么把这个方法改为对象的方法,要么就用Ttest申明的对象来调用:如下
       Ttest的对象.btn1.Caption:='ttt'