datagridview 表格

来源:互联网 发布:有限元软件 编辑:程序博客网 时间:2024/04/30 15:56

插入行 

this.dataGridView1.Rows.Add("V1", "Tokyo,日本","200ms");

this.dataGridView1.Rows.Add("V2", "新加坡", "110s");


设置当前表格,[2,1] 表示表格体的,第2列,第1行,行列序号从0开始的。

this.dataGridView1.CurrentCell = dataGridView1[2, 1];  


winform DataGridView 选择行 获取数据

  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();
        }


0 0