如何在vb.net中添加事件处理程序 [英] How to add eventhandlers in vb.net
本文介绍了如何在vb.net中添加事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在vb.net中添加addhandler和addressof
how to add addhandler and addressof in vb.net
推荐答案
看看
Take a look at this. You can find what you''re looking for in the solution provided by Sergey Alexandrovich.
imports System
imports System.Drawing
imports System.Windows.Forms
public class AddressOfEvent : inherits System.Windows.Forms.Form
Private WithEvents btn as Button
public sub New()
btn = new Button()
btn.Location = new Point(50,50)
btn.Text = "Test"
Controls.Add(btn)
AddHandler btn.Click, AddressOf btn_Click
end sub
public shared sub Main()
Application.Run(new AddressOfEvent())
end sub
private sub btn_Click(ByVal sender as object, _
ByVal e as EventArgs)
MessageBox.Show("btn_Click method","Events Demonstration")
end sub
private sub btn_ClickHandles(ByVal sender as object, _
ByVal e as EventArgs) _
Handles btn.Click
MessageBox.Show("btn_ClickHandles method","Events Demonstration")
end sub
end class
这篇关于如何在vb.net中添加事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文