本文介绍了未触发Datagrid cellvalidating事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

vs2008 + datagridview + cellvalidating事件未触发....同时更改了特定单元格的值.


任何帮助!!!

hi!!

vs2008 + datagridview + cellvalidating event not fire....while change the value of particular cell.


any Help!!!

推荐答案

private void dataGridView1_EditingControlShowing(object sender,
    DataGridViewEditingControlShowingEventArgs e)
{
    dataGridView1.EditingControl.KeyPress -= new KeyPressEventHandler(MyKeyPressHandler);
    dataGridView1.EditingControl.KeyPress += new KeyPressEventHandler(MyKeyPressHandler);
}



通过检查EditingControlShowing处理程序的参数,您可以选择要验证的单元格,也可以对每个单元格使用不同的按键处理程序.
请注意,按键处理程序在添加之前已被删除.这是为了防止在您继续进入单元格时建立相同的处理程序.删除不存在的处理程序(在第一次进入时)不是问题.



By checking the arguments to the EditingControlShowing handler you can be selective about the cells you decide to validate, or use different key press handlers for each cell.
Note that the key press handler is removed before it is added. This is to prevent a build up of identical handlers when you keep entering a cell. Removing a handler which doesn''t exist (on first entry) isn''t a problem.


这篇关于未触发Datagrid cellvalidating事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 09:50