如何获得form1的鼠标xy坐标。并在form2中的textbox中显示出来? 用get和set吗?还想知道获得一组form1的xy数据。不过还是实现一个再说。嘿嘿 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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(); } } }} form1 MouseMove事件绑定form2里的方法 其实很简单~你不要把显示在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(); } } }} 我其实就是不太懂那个get和set到底是怎么用的?以前没有接触过,今天才刚知道的。不理解这个get。我还想把form2中的数据提取出来。那怎么才算是form2中的数据?public TextBox MyTextBox{ get{ return textbox1; } } 只是加句这个就行了吗? 如何更改tableadapter中连接的数据库类型 datagridview绑定List<Point>后出错~ windows sdk for .net 3.0 昨天提问没有解决的!请高手指点! [求助]一个简单的动态数组的问题. 大家看看这个读取Xml文件的程序有什么问题啊?? 怎么处理没有文件名的文件? 突然发现我的可用分增加了不少。过来散分,并问个问题! 求一个类似DataGridView的第三方控件 一个有关属性的问题 谁做过自动登录软件? 反射问题 。
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();
}
}
}
}
其实只要有变量指向那个文本框就行了~~如果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();
}
}
}
}
不理解这个get。我还想把form2中的数据提取出来。那怎么才算是form2中的数据?
public TextBox MyTextBox{
get{
return textbox1;
}
} 只是加句这个就行了吗?