用GridView的MouseDown事件,具体代码如下:
private void gViewActPara_MouseDown(object sender, MouseEventArgs e) { GridHitInfo hint = gViewActPara.CalcHitInfo(e.X, e.Y); if (gViewActPara.RowCount == 0 || /*记录数大于0*/ !hint.InRowCell /*有效的单元格*/|| e.Button != MouseButtons.Left /*鼠标左键*/|| e.Clicks != 1 /*单击*/ ) { return; } if (hint.Column.FieldName == "需要弹出窗体的列名及该列的FieldName") { //强转当前行(避免鼠标点击的行与焦点行FocusedRowHandle不一致,鼠标点击时,焦点行FocusedRowHandle还未转换) gViewActPara.FocusedRowHandle = hint.RowHandle; //打开窗体的代码及处理略 //如果获取到打开窗体的值之后,需要更新到GridView上使用 // gViewActPara.SetRowCellValue(hint.RowHandle, "需要接受值列的FieldName",从窗体获取到的值); //使用SetRowCellValue会触发gViewActPara_CellValueChanged事件 } }
Dev GridView RowCellClick事件与MouseDown事件
原文:http://blog.csdn.net/jiankunking/article/details/44246145