C#窗口间数据交换问题 我在一个窗口里用datagridview控件显示数据库里的数据,要添加数据时,点添加按钮弹出另一个窗口,我想在数据填完后,点确定按钮,将数据保存在数据库里,并在第一个窗口的datagridview控件里显示出来,该怎么做 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在Form1中buttonclickForm2 frm = new Form2();frm.ShowDialog();//在form2中进行添加数据//可重新邦定,或者手工添加datagridview.Rows.Add(); winform间传值public partial class Form1 : Form { private void button1_Click(object sender, EventArgs e) { Form2 frm2 = new Form2(); frm2.Show(this); } } public partial class Form2 : Form { private void button1_Click(object sender, EventArgs e) { Form1 frm1 = (Form1)this.Owner; ((TextBox)frm1.Controls["textBox1"]).Text = this.textBox2.Text; this.Close(); } } 建议用一个context...内容上下文机制...Form2 frm = new Form2();frm.context=this.context;类似于这样的代码上下文机制的味道要不直接操作另一个form的味道要好... 另存对话框 XFire在Eclipse中开发webservice,C#中调用:中文为乱码! asp.net中gridview填充数据库的问题 安装了自己打包的部署之后,无法正常打开站点 急!!! 存储过程传参? (100分)求 C# 如何通过代理服务器发邮件 TcpClient服务器无响应时如何减少CONNECT等待时间 如何在查询时显示进度? Excel导出到dataset出错?明明是空白的网格,为什么还需要删除空白行,或者列? 能不能做呀?? 怎么在MDI中以showDialog方式打开子窗体? 能否给datagridview的列头设置背景图片?
buttonclick
Form2 frm = new Form2();
frm.ShowDialog();//在form2中进行添加数据
//可重新邦定,或者手工添加
datagridview.Rows.Add();
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show(this);
}
} public partial class Form2 : Form
{
private void button1_Click(object sender, EventArgs e)
{
Form1 frm1 = (Form1)this.Owner;
((TextBox)frm1.Controls["textBox1"]).Text = this.textBox2.Text;
this.Close();
}
}
frm.context=this.context;类似于这样的代码上下文机制的味道要不直接操作另一个form的味道要好...