当前位置:编程学习 > C#/ASP.NET >>

在两个窗体传值时循环打开Form1和Form2

Form1和Form2都 中有两个richtextbox和一个button用于相互传值 如同聊天窗口一样
代码:
Form1:
public partial class Form1 : Form
    {
        public string returnValue;
        public Form1()
        {
            InitializeComponent();
            //this.richTextBox1.Text = txtValue;
            string txtValue = this.richTextBox1.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            returnValue = this.richTextBox1.Text;
            string txtValue = this.richTextBox2.Text;
            Form2 f2 = new Form2(txtValue);
            f2.ShowDialog();
            this.richTextBox2.Text = f2.returnValue;
        }

Form2:
public partial class Form2 : Form
    {
        public string returnValue;
        public Form2(string txtValue)
        {
            InitializeComponent();
            this.richTextBox1.Text = txtValue;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            returnValue = this.richTextBox1.Text;
            string txtValue = this.richTextBox2.Text;
            Form1 f1 = new Form1();
            f1.ShowDialog();
            this.richTextBox2.Text = f1.returnValue;
        }
求大神 帮忙解决一下! c# --------------------编程问答--------------------

你这代码看得我心凉凉的, --------------------编程问答-------------------- From 1

        FT t = new FT();
        private void btnLink_Click(object sender, EventArgs e)
        {        
            t.sendM += new FT.send(t_sendM);
            t.Show();
            btnLink.Enabled = false;
        }

        void t_sendM(string mess)
        {
            txtMessage.Text += "\r\n"+mess;
        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            t.txtMessage.Text += "\r\n" + txtSend.Text; ;
        }


From 2

      public delegate void send(string mess);
       public event send sendM;

        private void FM_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            sendM(txtSend.Text);
        }
--------------------编程问答-------------------- http://bbs.csdn.net/topics/360140208
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,