如何从其他表单编辑datagridview [英] How can I edit datagridview from another form
问题描述
在form1上我有一个datagridview,一旦选择了一行并单击了adjust按钮,它将显示form2,其中包含form1上所选行的详细信息。如何编辑form2,以便它将在form1上显示已编辑的form2。我有这个代码......
$ 1 $ b表格1
<前lang =C#> 私人 void button1_Click( object sender,EventArgs e)
{
adjust fr = new adjust();
fr.itemcodetxt.Text = this .dataGridView1.CurrentRow.Cells [ 0 ]。的ToString();
fr.currentquantity.Text = this .dataGridView1.CurrentRow.Cells [ 1 ]。的ToString();
fr.pricetxt.Text = this .dataGridView1.CurrentRow.Cells [ 2 ]。的ToString();
fr.ShowDialog();
}
有人可以告诉我该怎么做???
我不确定我到底知道你想要什么,但是想尝试这样的事情是什么?:
adjust fr = new adjust();
fr.itemcodetxt.Text = this .dataGridView1.CurrentRow.Cells [ 0 ]。的ToString();
fr.currentquantity.Text = this .dataGridView1.CurrentRow.Cells [ 1 ]。的ToString();
fr.pricetxt.Text = this .dataGridView1.CurrentRow.Cells [ 2 ]。的ToString();
fr.ShowDialog();
this .dataGridView1.CurrentRow.Cells [ 0 ]。Value = fr.itemcodetxt.Text ;
this .dataGridView1.CurrentRow.Cells [ 1 ]。Value = fr.currentquantity.Text ;
this .dataGridView1.CurrentRow.Cells [ 2 ]。Value = fr.currentquantity.Text ;
On form1 i have a datagridview once a row is selected and adjust button is clicked, it will show form2 with the details of selected row on form1. How can I edit form2 so that it will show on form1 the edited one. I have this code...
on form1
private void button1_Click(object sender, EventArgs e)
{
adjust fr = new adjust();
fr.itemcodetxt.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
fr.currentquantity.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
fr.pricetxt.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
fr.ShowDialog();
}
Can Someone please show me how to do that???
I am not sure i understand exactly what you want, but what abouy trying something like this?:
adjust fr = new adjust(); fr.itemcodetxt.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); fr.currentquantity.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); fr.pricetxt.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); fr.ShowDialog(); this.dataGridView1.CurrentRow.Cells[0].Value=fr.itemcodetxt.Text; this.dataGridView1.CurrentRow.Cells[1].Value=fr.currentquantity.Text; this.dataGridView1.CurrentRow.Cells[2].Value=fr.currentquantity.Text;
这篇关于如何从其他表单编辑datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!