DatagridView事件处理问题 [英] DatagridView Event Handling Problem
本文介绍了DatagridView事件处理问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
海...
我可以从datagridview_Keypress事件中调用Datagridview_Celldoubleclick事件吗?当我按Enter键时,我必须执行单元格双击事件,因为在那种情况下我正在使用DataGridViewCellEventArgs,但是在keypress事件中我们不能使用此参数.还有其他方法吗?去做这个?请帮我...
谢谢
Sujith
Hai...
Can i call Datagridview_Celldoubleclick event from datagridview_Keypress Event?.When i press enter button ,i have to execute the cell double click event because in that event i am using DataGridViewCellEventArgs,but in keypress event we can not use this argument.Is there any other way to do this? Please help me...
With Thanks
Sujith
推荐答案
是的,您可以从另一个事件调用另一个事件处理程序.您只需要创建必要的参数即可.
但是,我建议您将实际代码与单独的方法分开使用,这样编码将更容易,更清晰.像这样的东西:
Yes you can call another event handler from another event. You just have to create necessary parameters.
However I suggest that you take the actual code to separate method so coding would be easier and much clearer. Something like:
void datagridview_Keypress(...) {
MyMethod(...);
}
void Datagridview_Celldoubleclick(...) {
SomeOtherMethod(...);
MyMethod(...);
}
void MyMethod(...) {
... actual code ...
}
void SomeOtherMethod(...) {
... actual code ...
}
这篇关于DatagridView事件处理问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文