[英]how to create custom events in vb.net
Is it possible to create my own event in vb.net . 是否可以在vb.net中创建我自己的事件。
I need an event for WindowState = Normal. 我需要WindowState = Normal的事件。
You can use the SizeChanged
event to monitor changes to WindowState
. 您可以使用
SizeChanged
事件来监视对WindowState
更改。 Then you can expose your own custom event that is raised when it changes: 然后,您可以公开自己的自定义事件,该事件在更改时引发:
Public Event WindowStateChanged As EventHandler
Private currentWindowsState As FormWindowState
Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
MyBase.OnSizeChanged(e)
If WindowState <> currentWindowsState Then
currentWindowsState = WindowState
OnWindowStateChanged(EventArgs.Empty)
End If
End Sub
Protected Sub OnWindowStateChanged(ByVal e As EventArgs)
RaiseEvent WindowStateChanged(Me, e)
End Sub
This sample will raise the WindowStateChanged
event whenever it changes, regardless of from what state and to what state. 无论何时从什么状态到什么状态,此示例都将引发
WindowStateChanged
事件。 You can easily add conditions to raise it only for certain states. 您可以轻松地添加条件以仅针对某些状态提高它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.