我想在一个主窗体(Frmmain)的弹出窗体(Frm1)里访问主窗体中是一个按钮(Button1),此代码应如何写呢?

解决方案 »

  1.   

    參見
    http://blog.csdn.net/tjvictor/archive/2006/06/23/824617.aspx
      

  2.   

    参考
    http://blog.csdn.net/dyw31415926/archive/2006/10/16/1336631.aspx
      

  3.   

    那上面说的都是传值,可是怎么访问控件呢?
    Formmain里有一个控件Button1,它的初始Enabled为False
    现在我想在Form2里令它的Enabled为True,
    此代码应如何写呢?
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;namespace FormMdi
    {   
        static class Program
        {
            public static Form1 form1 ;
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {   //Form1 form1=new Form1();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                form1 = new Form1();/////重点在这
                Application.Run(form1);
            }
        }
    }
    在第二窗体里Program.form1就行了