且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从WPF按钮单击事件中引发winforms用户控件按钮单击事件

更新时间:2021-10-12 08:20:32

As提升winforms用户控制按钮点击事件我理解你想要的那个例子,例如由UserControl上的Button引发的Click-Event应该来自UserControl。 UserControl上的Button不应该在Control之外。



如果这是正确的,你只需要捕获UserControl中的Button.Click(用一个简短的方法) )并使用此方法从UserControl调用(受保护的)OnClick方法。
As I understood your requirement you want that for example the Click-Event, which is raised by the Button on the UserControl, should come from the UserControl. The Button on the UserControl should not be known outside the Control.

If this is right you only need to catch the Button.Click inside the UserControl (with a short method) and with this method you call the (protected) OnClick-Method from the UserControl.