在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace UserControls { public partial class UserControl1 : UserControl { public delegate void MyDelegate(object sender, EventArgs e);//建立委托 public MyDelegate myEven_click; public UserControl1() { InitializeComponent(); button1.Click += new EventHandler(button1_Click); //绑定委托事件 } private void button1_Click(object sender, EventArgs e) { if (myEven_click != null) { myEven_click(sender, e); } } } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace 自定义控件的点击事件 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { userControl11.myEven_click += new UserControls.UserControl1.MyDelegate(fuzhi);//把事件绑定到自定义的委托上 } public void fuzhi(object sender ,EventArgs e) { label1.Text = "456"; } } }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论