prevent窗口窗体DataGridView单元格编辑后更改的行 [英] Prevent windows forms datagridview to change row after cell edit
本文介绍了prevent窗口窗体DataGridView单元格编辑后更改的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个DataGridView Windows窗体,默认的行为,当值的编辑是一个小区,当我preSS进入,所选择的行更改到下一个。
I have a datagridview in windows forms, the default behavior when editing values is that after the edition of a cell, when I press enter, the selected row changes to the next.
我不想说,我要退出编辑模式,但住在同一个小区。
I don't want that, I want to exit edit mode but staying in the same cell.
这可能吗?
推荐答案
您可以自定义的DataGridView
覆盖 ProcessDialogKey
方法:
You can customize the DataGridView
to override the ProcessDialogKey
method:
public class CustomGrid : DataGridView {
protected override bool ProcessDialogKey(Keys keyData) {
if (keyData == Keys.Enter) {
EndEdit();
return true;
}
return base.ProcessDialogKey(keyData);
}
}
这篇关于prevent窗口窗体DataGridView单元格编辑后更改的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文