Detect user click close button, alt + f4 or using method Me.Close()

0 thích 0 không thích
1 lượt xem
đã hỏi 30 Tháng 3, 2023 trong Lập trình VB.NET bởi nguyenthao (9,000 điểm)
Private Sub sxcad_setup_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        If New StackTrace().GetFrames().Any(Function(x) x.GetMethod().Name = "Close") Then
            MessageBox.Show("Closed by calling Close()")
        Else
            MessageBox.Show("Closed by X or Alt+F4")
        End If
    End Sub
Looking for an answer?  Share this question:     

Xin vui lòng đăng nhập hoặc đăng ký để trả lời câu hỏi này.

...