dataGirdView编辑后按回车键怎么触发CellEndEdit事件
dataGirdView编辑后按回车键如何触发CellEndEdit事件
dataGirdView单元格编辑后按回车键如何触发CellEndEdit事件
看似很简单,请大家帮忙
------解决思路----------------------
写一个类继承DataGridView,重写OnKeyPress方法
dataGirdView单元格编辑后按回车键如何触发CellEndEdit事件
private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)//回车
{
// do sth
}
}
private void dataGridView3_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show(e.RowIndex.ToString());
}
看似很简单,请大家帮忙
------解决思路----------------------
写一个类继承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));
}
}
}