自定义用户控件中子控件的事件处理程序 [英] Event Handlers for Child Controls in the Custom User Control

查看:96
本文介绍了自定义用户控件中子控件的事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我创建了一个自定义控件,该控件在面板上有两个按钮.还实现了Button1和button2上的"click"事件的事件处理程序.
但是现在在应用程序中使用了Custom Control Dll.单击button1时.我希望在Form_1中的Label_1中填充在Text Box_1中输入的值.但是无法在Custom中的事件处理程序中添加此代码.作为自定义控件的控件库不了解Form_1上的控件.

非常感谢您提供任何帮助,以修改自定义控件的事件处理程序并在使用它的Windows应用程序中使用它.

Hi,
I Created a custom control which has Two buttons on a panel.The event handler for the "click" event on the Button1 and button2 are also implemented.
But now the Custom Control Dll is used in an application.When the button1 is clicked..I want a Label_1 in the Form_1 to be populated with a value entered in Text Box_1.But this code cannot be added in the event handler in the Custom Control Library as the custom control is unaware of the controls on the Form_1.

Any help is greatly appreciated as to modify the event handler of the custom control and to use it in the Windows Application which uses it.

推荐答案

公开两个事件,Button1Clicked和Button2Clicked.处理控件中的两个按钮单击并触发这些自定义事件.在应用程序上,人们可以订阅此事件并得到通知.
Expose two events, Button1Clicked and Button2Clicked. Handle the both button clicks in your control and fire these custom events. On the application, people can subscribe to this event and they get notified.


我是C#的新手.但是如何触发自定义事件?
I am new to C#..But How to fire a Custom Event?


这篇关于自定义用户控件中子控件的事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆