Articles in categories

Now on Amazon

Stieven's Corner

Detect ParentForm closing from a UserControl VB

    Private Sub MyControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim f As Form = Me.FindForm
        If Not IsNothing(f) Then
            AddHandler f.Closing, AddressOf Me.Handler_ParentFormClosing
        End If
    End Sub

    Private Sub Handler_ParentFormClosing(ByVal sender As Object, ByVal e As CancelEventArgs)
        'cancel closing of the parentform
				If Condition Then
						e.Cancel = True
				End If
    End Sub