發(fā)布時(shí)間:2020-08-06 09:11 作者:獨(dú)孤劍 閱讀:2135
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsFormsApp3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void myUserControl1_TestClick(object sender, EventArgs e) { MessageBox.Show("用戶點(diǎn)擊2"); } } public partial class MyUserControl : UserControl { public MyUserControl() { // 注冊(cè)事件 this.Click += new System.EventHandler(this.MyUserControl_Click); } /// <summary> /// 自定義事件 /// </summary> public event System.EventHandler TestClick; /// <summary> /// 單擊事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MyUserControl_Click(object sender, EventArgs e) { if (TestClick != null) TestClick(sender, e); } } }
微信打賞, 微信掃一掃
支付寶打賞, 支付寶掃一掃
如果文章對(duì)您有幫助,歡迎給作者打賞