Passing row form datagridview form 1 to datagridview form 2
Form 1
Form 2
How to write the code for:
when click the row 开发者_如何学运维at form 1 datagridview, form 1 will close and and open form 2 with the datagridview together with the row selected in 1 and also send data( shelf/level) to PIC?
This is a sample code Try this as per your requirement
private void Button1_Click(object sender, EventArgs e)
{
String str1 = String.Empty
String str2 = String.Empty
str1 = this.DataGridView1.Rows(0).Cells(0).Value.ToString()
str2 = this.DataGridView1.Rows(0).Cells(1).Value.ToString()
Form2 f2=new Form2(str1,str2)
f2.Showdialog()
}
Form2 code
public Form2(string str1,string str2)
{
InitializeComponent();
dataGridView1.Columns.Add("C", "C1");
dataGridView1.Columns.Add("C","c2");
dataGridView1.Rows.Add(str1, str2);
}
精彩评论