用get和set吗?
还想知道获得一组form1的xy数据。不过还是实现一个再说。嘿嘿

解决方案 »

  1.   


    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            Form f2;
            TextBox txt;
            public Form1()
            {
                InitializeComponent();
                f2 = new Form();
                txt = new TextBox();
                f2.Controls.Add(txt);
                f2.Show();
                this.MouseMove += new MouseEventHandler(Form1_MouseMove);
            }        void Form1_MouseMove(object sender, MouseEventArgs e)
            {
                if (txt!=null) {
                    txt.Text = e.Location.ToString();
                }
            }
        }
    }
      

  2.   

    form1 MouseMove事件绑定form2里的方法
      

  3.   

    其实很简单~你不要把显示在form2上的文本框想当然它就是form2的东西~~
    其实只要有变量指向那个文本框就行了~~如果form2是你自己做的form,那么可以给form2加一个属性public TextBox MyTextBox{
        get{
          return textbox1;
       }
    }namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            Form2 f2;
            public Form1()
            {
                InitializeComponent();
                f2 = new Form2();
                f2.Show();
                this.MouseMove += new MouseEventHandler(Form1_MouseMove);
            }        void Form1_MouseMove(object sender, MouseEventArgs e)
            {
                if (f2!=null) {
                    f2.MyTextBox.Text = e.Location.ToString();
                }
            }
        }
    }
      

  4.   

    我其实就是不太懂那个get和set到底是怎么用的?以前没有接触过,今天才刚知道的。
    不理解这个get。我还想把form2中的数据提取出来。那怎么才算是form2中的数据?
    public   TextBox   MyTextBox{ 
            get{ 
                return   textbox1; 
          } 
    } 只是加句这个就行了吗?