开发者

how to create custom events in vb.net

开发者 https://www.devze.com 2023-02-10 02:01 出处:网络
Is it possible to create my own event in vb.net . I need an event for Windo开发者_如何学JAVAwState = Normal. You can use the SizeChanged event to monitor changes to WindowState. Then you can expose

Is it possible to create my own event in vb.net .

I need an event for Windo开发者_如何学JAVAwState = Normal.


You can use the SizeChanged event to monitor changes to 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. You can easily add conditions to raise it only for certain states.

0

精彩评论

暂无评论...
验证码 换一张
取 消