datagridview 用什么事件单击一行,然后把提示信息,判断选择是不是要更改一当前行的一个单元格的内容

来源:百度知道 编辑:UC知道 时间:2024/05/26 01:18:17
FORM的 新手学习中,请指点源码.

首先:
this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;//设置为整行被选中

然后,在dataGridView的CellClick事件中提示是否要修改当前行当前单元格的内容:
DialogResult result=MessageBox.Show("是否要修改当前行中单元格的内容?","提示信息",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (this.dataGridView1.SelectedRows.Count > 0)
{
if (result == DialogResult.Yes)
{
//修改当前行单元格的内容
}
}

获取当前行单元格内容:
string str = this.dataGridView1.CurrentRow.Cells["列名"].Value;

LZ试试吧~~直接用手敲的,没在程序中运行。