hehe,你这样当然不行了,你又new了一个form,你是给这个新form设置了,你应该在你的Mclass.Set方法再接受一个参数,把form对象传过去。

解决方案 »

  1.   

    public void Set(string s)
    {
        form.textBox1.Text=s;
    }
    这个函数应该增加 mainForm form 作为参数,,不要在public class MClass//自定义的普通类
    中重新实例化mainForm ,,这样你在按钮事件中就可以mc.Set(this,"sdfsf"); 就ok了
      

  2.   

    建议使用属性
    namespace RLink
    {
    public class MClass//自定义的普通类
    {     
                   ......
                   mainForm form=new mainForm(); private string _s; public String MyText
    {
    get{return _s;}
    set{_s = value;}
    }               //按钮事件是新建一个普通类的对象,并调用Set(string s)函数进行设置
    /*public void Set(string s)
    {
        form.textBox1.Text=s;
    }*/
                  ...... private void MClass_Load(object sender, System.EventArgs e)
    {
    this.textBox1.Text = MyText;
    }
             }}namespace RLink
    {
    public class mainForm : System.Windows.Forms.Form//主窗体类
    {     
                   ......
                   public System.Windows.Forms.TextBox textBox1;               //按钮事件是新建一个普通类的对象,并调用Set(string s)函数进行设置
                   private void button1_Click(object sender, System.EventArgs e)
         {
    MClass mc=new MClass();
    mc.MyText = "sdfsf";
         }
                  ......
             }}
      

  3.   

    方法一:
    -------------------主窗体: private void button1_Click(object sender, System.EventArgs e)
    {
    Class1 class1 = new Class1(this.textBox1);
    class1.Set("aaaaaaaa");
    }
    自定义的普通类 Class1:using System;namespace WindowsApplication8
    {
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    public class Class1
    {
    System.Windows.Forms.TextBox f; public Class1(System.Windows.Forms.TextBox F)
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    f = F;
    } public void Set(string s)
    {
    f.Text = s;
    }
    }
    }
      

  4.   

    moonewxp(母牛) 说得没错 。
      

  5.   

    把你的TextBox控件对象传给你的Class