Form1:
public static string[] a;
private void dataGridView1_DoubleClick(object sender, EventArgs e)//添加datagridview1的双击事件
{
做族 try
蠢搜 {
int index = dataGridView1.CurrentRow.Index;
a = new string[dataGridView1.ColumnCount];
for (int i = 0; i < dataGridView1.ColumnCount; i++)
{
a[i] = dataGridView1.Rows[index].Cells[i].Value.ToString();
}
Form2 f2 = new Form2();
f2.Show();
}
catch { }
}
Form2://
public Form2()
{
InitializeComponent();
showGridView();
}
private void showGridView()
{
DataGridTextBoxColumn tb = new DataGridTextBoxColumn();
带胡历 dataGridView1.Rows.Add(tb);
for (int i = 0; i < dataGridView1.ColumnCount;i++ )
dataGridView1.Rows[dataGridView1.RowCount-2].Cells[i].Value = Form1.a[i];//根据AllowUserToAddRow属性选择最后一行,true时dataGridView1.RowCount-2,false时dataGridView1.RowCount-1
}