C#运行时出现dataGridView这个表格,我想鼠标点击哪一行,然后MessageBox就显示这行的全部信息。

解决方案 »

  1.   

    用CellClick事件dgv.Rows[e.RowIndex].Cells["NAME"].Value.ToString();
      

  2.   


    private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
            {
                string tmpDisplay = string.Empty;
                for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
                {
                    tmpDisplay = tmpDisplay + this.dataGridView1.Rows[e.RowIndex].Cells[i].Value.ToString();
                }
                MessageBox.Show(tmpDisplay);
            }
      

  3.   

    最好的方式不是这个,而是使用BindingSouce做中介那么dataGridView1_CellContentClick里面 this.bindingSource1.Current 对象就是lz要的东西