如何从其他表单编辑datagridview [英] How can I edit datagridview from another form

查看:60
本文介绍了如何从其他表单编辑datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆