日期:2014-05-18  浏览次数:20866 次

dataGridView1的指定单元格离开时触发什么事件,怎么写
如 有3行3列,我在第2行2列离开时,能读取到2行2列的数据,并且把值赋值到 当前行的3列


怎么写方法,感谢

------解决方案--------------------
void dataGridView_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView.RowCount >= 2 && dataGridView.ColumnCount >= 2)
{
if (dataGridView.CurrentCell.RowIndex == 1 && dataGridView.CurrentCell.ColumnIndex == 1)
{
object cellValue = dataGridView[1, 1].Value;
dataGridView[2, dataGridView.CurrentCell.RowIndex].Value = cellValue;
}
}
}
------解决方案--------------------
用当前单元格变更时的哪个事件...
dataGridView1_CurrentCellChanged 查看e.rowindex 与dgv1.currentcell.index LZ试下是否可以得到效果

dataGridView_CellMouseLeave 这个事件无法兼顾到键盘操作吧...
------解决方案--------------------
探讨
void dataGridView_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView.RowCount >= 2 && dataGridView.ColumnCount >= 2)
{
if (dataGridView.CurrentCell.RowIn……