form1是主窗体
form2中有1个单选钮对象"radiogroup1"我在form1的一个自定义函数中写下
"if form2.radiogroup1.checked=True then showmessage('ok');"可以编译通过.
但运行到此处时提示出错.不知错在那里?

解决方案 »

  1.   

    方法一:
    菜单 file->use unit...
    然后选择 unit2(unit2 是form2的文件,unit1 为form1)方法二:
    在代码编辑框
    implementation 后面加上
    uses Unit2;
      

  2.   

    form2没获得焦点;不能对它的控件属性进行操作吧;
      

  3.   

    如果编译通过,可能是 form2 没有创建实例
      

  4.   

    跟你的form2窗体类型有关,如果是fsNormal肯定不能运行,通过如果fsMdichild能运行
      

  5.   

    我已在form1中用以下命令调用:with TForm2.Create(self) do
       try
         ShowModal;
       finally;
         free;
       end;
    end;并且已在form1的implementation 后面加上uses Unit2;
      

  6.   

    如果照你上面的写法,Form2 关闭后,就被 Free 了,你又怎么取得它上面的东西呢?
    with TForm2.Create(self) do
       try
         ShowModal;
         if radiogroup1.checked=True then showmessage('ok');
       finally;
         free;
       end;
    end;
      

  7.   

    同意楼上的,应该是Form2已经释放掉了。
      

  8.   

    for example, you want to use the button1 that is included in form2,you can do as follows:
       at first, you  must use 'unit2.pas' in unit1.pas ,then you can add the code:
      procedure.......
      begin 
      form2.button1....
      end;
     
      that is so easy!