当前位置:编程学习 > C#/ASP.NET >>

关于DATAGRIDVIEW

我在一个datagridview里面放了表的部分列,当我鼠标选中一行之后,想在同一个form里面其他地方使用这一行某列的数据,请问应该怎么弄?
详细点吧 --------------------编程问答-------------------- private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {

            textBox1.Text =dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells["id"].Value.ToString()  ;
            textBox2.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["name"].Value.ToString();
        }
--------------------编程问答--------------------
引用 1 楼 wuyq11 的回复:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  {

  textBox1.Text =dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells["id"].Value.ToString() ;
  textBox2……

Up
最主要 this.dataGridView.CurrentRow.Index --------------------编程问答--------------------
引用 1 楼 wuyq11 的回复:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  {

  textBox1.Text =dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells["id"].Value.ToString() ;
  textBox2……

upup --------------------编程问答-------------------- 在CellClick事件中添加代码即可 --------------------编程问答-------------------- --------------------编程问答--------------------

//Rows属性引用所有的行
//一个行的Cells属性引用所有的列,就是这样找到数据的。

//CurrentRow表示当前选中行
dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells["id"].Value.ToString() ;
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,