本文介绍了DataGridView,如何捕获单元格的KeyPress事件以捕获Enter/Up/Down键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在datagridview中捕获单元格的按键事件.
我正在使用以下代码,但是通过此代码,无法捕获Enter/Down键.
How to capture the cell''s keypress event in datagridview.
i am using following code, but by this code Enter/Down keys are not capturing.
void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
TextBox txtbox = e.Control as TextBox;
if (txtbox != null)
{
txtbox.KeyPress += new
KeyPressEventHandler(txtbox_KeyPress);
}
}
void txtbox_KeyPress(object sender, KeyPressEventArgs e)
{
MessageBox.Show(e.KeyChar.ToString());
}
如何在数据网格视图的单元格中捕获Enter/Down/Up键?
请帮助
What to do for capturing Enter/Down/Up key in the cell of data grid view?
Please Help
推荐答案
这篇关于DataGridView,如何捕获单元格的KeyPress事件以捕获Enter/Up/Down键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!