写一个类继承DataGridView,重写OnKeyPress方法
public class DataGridViewEx : DataGridView
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e); if (this.CurrentCell == null || this.CurrentCell.RowIndex < 0 | this.CurrentCell.ColumnIndex < 0) return; if (e.KeyChar == (char)Keys.Enter) {
OnCellEndEdit(new DataGridViewCellEventArgs(this.CurrentCell.ColumnIndex, this.CurrentCell.RowIndex));
}
}}
public class DataGridViewEx : DataGridView
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e); if (this.CurrentCell == null || this.CurrentCell.RowIndex < 0 | this.CurrentCell.ColumnIndex < 0) return; if (e.KeyChar == (char)Keys.Enter) {
OnCellEndEdit(new DataGridViewCellEventArgs(this.CurrentCell.ColumnIndex, this.CurrentCell.RowIndex));
}
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货