datagridview 中的数据通过鼠标单击 如何显示在textbox中
 请各位大虾指点

解决方案 »

  1.   

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

  2.   

    DataGridView的CellClick事件中设置textbox的Text即可。
    例如:
    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
    }