试了好多,都不行,我就想在网格中选中,然后让数据在下面的textBox中显示出来....谢谢各位了...

解决方案 »

  1.   

    this.dataGridView1.CurrentCell = this.dataGridView1[colIndex, rowIndex];
    object value = this.dataGridView1.CurrentCell.Value;
    if (value != null)
    {
    string strValue = value.ToString();
    }
      

  2.   

    private void dataGridView1_SelectionChanged(object sender, EventArgs e)
            {
                this.textBox1.Text = this.dataGridView1.CurrentCell.Value.ToString();
                           
                
                
            }
      

  3.   

    首先先选中 dataGridView1,然后找一个cellclick的事件.private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
            {            string str0 = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();//0为dataGridView1的索引值
                string str1 = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();//1为dataGridView1的索引值
                this.txtbox1.Text = str0;
                this.txtbox2.Text = str1;
            }