插入行
this.dataGridView1.Rows.Add("V1", "Tokyo,日本","200ms");
this.dataGridView1.Rows.Add("V2", "新加坡", "110s");
设置当前表格,[2,1] 表示表格体的,第2列,第1行,行列序号从0开始的。
this.dataGridView1.CurrentCell = dataGridView1[2, 1];
private void WorkerGrid_SelectionChanged(object sender, EventArgs e)
{
this.WorkerGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
txtwid.Text = this.WorkerGrid.CurrentRow.Cells[0].Value.ToString();
this.txtwname.Text = this.WorkerGrid.CurrentRow.Cells[1].Value.ToString();
this.txtwcard.Text = this.WorkerGrid.CurrentRow.Cells[2].Value.ToString();
this.txtwphone.Text = this.WorkerGrid.CurrentRow.Cells[3].Value.ToString();
this.txtaddress.Text = this.WorkerGrid.CurrentRow.Cells[4].Value.ToString();
}