调用按钮的点击编程方法 [英] Invoking the click method of a button programmatically
问题描述
简单的问题,(我认为):我希望能够调用点击方法predefined对象,特别是在标准C#中的 bindingNavigatorDeleteItem
按钮 BindingNavigator
。我需要拦截删除,这样我可以验证该记录允许被删除。如果是,我想调用上述单击事件做哪些删除了很好的工作,说的纪录。如果记录不符合删除,我想中止删除。
Simple problem (I think): I want to be able to invoke a click method on a predefined object, specifically, the bindingNavigatorDeleteItem
button on the standard c# BindingNavigator
. I need to intercept the delete so that I can verify that the record is allowed to be deleted. If it is, I want to invoke the aforementioned click event which does a nice job of deleting said record. If the record is not eligible for deletion, I want to abort the delete.
我的一个工程同事建议我只需添加另一个按钮的工具条,并用它的Click方法(当然,我的可以的到达)检查记录的资格,并调用原始根据需要删除按钮。
An engineering colleague of mine suggests that I simply add another button to the toolstrip and use it's click method (which, of course, I can get to) to check the records eligibility and call the original delete button as needed.
如果有另一种更好的方法,请传递下去吧。
If there is another, better way, please pass it along.
推荐答案
要简单地调用点击 - 你应该可以使用 PerformClick()
To simply invoke the click - you should be able to use PerformClick()
.
我有一点你所提到的其他东西失去了 - 你能澄清
I was a little lost by the other things you mentioned - can you clarify?
这篇关于调用按钮的点击编程方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!