向datagridview添加一行
1 2 3 4 5 6 |
DataGridViewRow dgvRow = dataGridView1.Rows[dataGridView1.Rows.AddCopy(0)]; dgvRow.Cells[0].Value = dgvRow.DataGridView.NewRowIndex.ToString("D"); dgvRow.Cells[1].Value = data.Substring(data.IndexOf("txtKeyWord=", System.StringComparison.Ordinal) + 11, 8); dgvRow.Cells[2].Value = data; 选择一行的方式 |
1 2 |
dataGridView1.CurrentCell = dataGridView1.Rows[idx].Cells[0];//设置目标行为当前行 dataGridView1.Rows[idx].Selected = true;//选择目标行 |