窗体A上 点击一个按钮调用 B类中的方法对数据进行处理,处理时返回处理消息,同时对消息进行分析,请教分析结果怎么返回到窗体A上
在线等~~

解决方案 »

  1.   

    B类中用事件进行返回,event Action<MsgClass>,MsgClass是你的消息类。
    A中订阅这个事件,分析完成后绘制到窗体上要用BeginInvoke,不可以直接绘制。
      

  2.   

    btn1_Click(obejct sender,EventArgs e)
    {
        B b = new B();
        结果 = b.处理();
        把结果显示在界面上
    }如果用多线程的话
    参考BackgroundWorker类  
      

  3.   

    B中用Action<YourMsgClass>通知A。
    A分析完成后用BeginInvoke绘制到界面。
      

  4.   

    这样说吧  B中定义了List<string>  str
    A窗体中怎么获取到这个str
      

  5.   

    楼主是b/s 还是 c/s  
      

  6.   


    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        public string passText
            {
                get {
                    return textBox1.SelectedText.Text;
                }
            }        private void button1_Click(object sender, EventArgs e)
            {
                Form2 f2 = new Form2();
                f2.Owner = this;
                f2.Show();
            }        private void Form1_Load(object sender, EventArgs e)
            {        }        private void textBox1_TextChanged(object sender, EventArgs e)
            {
                if(this.OwnedForms.Length != 0)
                (this.OwnedForms[0] as Form2).selectText = textBox1.Text;/*OwnedForms是一个数组 ,表示当前对象拥有的子窗体数组,同样要把通过下标得到的元素转换为Form2类型。*/
            }
        }
    }namespace WindowsApplication1
    {
        public partial class Form2 : Form
        {
            public string selectText
            {
                set
                {
                    textBox1.Text = value;   //设置一个属性,让form1操作
                }
            }        public Form2()
            {
                InitializeComponent();
            }        private void Form2_Load(object sender, EventArgs e)
            {
                textBox1.Text = ((Form1)this.Owner).passText;
            }
        }
    }