0
我有一個datagridview,而雙擊一行,它應該增加其高度,並顯示該行內的另一個datagridview。如何插入另一個DataGridView。 我的代碼如下想要添加新的datagridview現有datagridview選定行內
private void Form1_Load(object sender, EventArgs e)
{
DataGridViewColumn col = new DataGridViewTextBoxColumn();
col.HeaderText = "Name";
dataGridView1.Columns.Add(col);
DataGridViewColumn col1 = new DataGridViewTextBoxColumn();
col1.HeaderText = "Address";
dataGridView1.Columns.Add(col1);
DataGridViewColumn col2 = new DataGridViewTextBoxColumn();
col2.HeaderText = "Age";
dataGridView1.Columns.Add(col2);
DataGridViewColumn col3 = new DataGridViewTextBoxColumn();
col3.HeaderText = "Education";
dataGridView1.Columns.Add(col3);
for (i = 0; i < 5; i++)
{
dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells[0].Value = "Name";
dataGridView1.Rows[i].Cells[1].Value = "Address";
dataGridView1.Rows[i].Cells[2].Value = "Age";
dataGridView1.Rows[i].Cells[3].Value = "Education";
}
}
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Height = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Height + 40;
}