VB.Net - Call a Sub with events

前端 未结 3 1798
北恋
北恋 2021-01-27 05:35

Is it possible to Call a Sub with events?

I have the following sub, and when I press a button, I will trigger a Msgbox.

Public Class SelectLevel

    Pub         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-27 05:49

    If the event you need is only click event then there is an easy way PerformClick function

    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Button1.PerformClick()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("pressed")
    End Sub 
    End Class
    

提交回复
热议问题