+ -
当前位置:首页 → 问答吧 → 怎么获dataGridView中的数据

怎么获dataGridView中的数据

时间:2011-12-13

来源:互联网

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

作者: tang1390   发布时间: 2011-12-13

用CellClick事件
C# code

dgv.Rows[e.RowIndex].Cells["NAME"].Value.ToString();

作者: zhangbin1988   发布时间: 2011-12-13

C# code

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

作者: dreamboy0908   发布时间: 2011-12-13