把一个值从Form1传到Form2,并且在点击Form1上的按钮之后,From2上的控件内容就被改成从Form1上传过来的值,该怎么做呢?
不知道该怎么保持Form1在Form2消失之后还是同一个对象
请教各位~
不知道该怎么保持Form1在Form2消失之后还是同一个对象
请教各位~
解决方案 »
- |ZTCWPF| RichTextBox可以用FontWeightProperty取得粗体,FontStyleProperty取得斜体,那下划线是哪个属性 谢谢
- 做一个压缩功能
- 屏幕录制,写入avi时的一个小问题?????????????????????????????????????
- 渴求C#手机游戏开发入门教程
- listbox添迦数据
- 很菜的一个问题? 在线等。。。
- DataView 的 RowFilter 問題
- Linq:为什么orderby和thenby需要的接口不同?
- asp.net中的第归调用问题??可用分只有10分,嫌少的就不要进来了!!
- 什么语句一定要放在try ---catch 里面?
- Excel导入到数据库
- 修改windows服务配置后自动加载配置怎么做?
在Form2中,txtbox的内容取得为public在Form1中string stra;
Form2 frm2 = new Form2();
stra = frm2.txtbox.Text;当然是在同一个命名空间里
Form1中:
private void button6_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.youEvent += new EventHandler<Form2.yourEventArgs>(frm_youEvent);
frm.ShowDialog(this);
this.listBox1.UpdateHScrllBar();
}
Form2中:
public partial class Form2 : Form
{
public class yourEventArgs : EventArgs
{
private string m_value;
public yourEventArgs(string value)
{
this.m_value = value;
}
public string Value
{
get { return m_value; }
}
}
public event EventHandler<yourEventArgs> youEvent; public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (this.youEvent != null)
{
yourEventArgs args = new yourEventArgs(this.textBox1.Text);
this.youEvent(this, args);
}
}
}
http://www.cnblogs.com/tuyile006/archive/2006/07/04/442113.html