例点击A界面的datagridview 打开B界面;在B界面的textbox中输入文本,点击button传回到A界面的datagridview
点击datagridview的事件中写:
B b=new B()
if (b.ShowDialog() == DialogResult.OK)
{
datagridview.Rows[rowindex].Cells[columnindex].Value = b.text;
}
窗体B中这样设计
public string text; //要回传到datagridview的变量
public B()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
text=textBox1.Text; //给text赋值
this.DialogResult = DialogResult.OK;
}
catch (Exception ee)
{
MessageBox.Show(ee.ToString());
}
}