Question Hide a child form when it's deactivated

Pirahnaplant

Well-known member
Joined
Mar 29, 2009
Messages
75
Programming Experience
3-5
So, I have a form that is supposed to act like a ContextMenuStrip. It is shown when the user right clicks and needs to hide when it no longer has focus. To do so, here's the code I have within this form:
ShowThis will be called when the main form is right clicked.
VB.NET:
    Public Sub ShowThis(ByVal parent As Form)
        Me.Show(parent)
    End Sub

    Private Sub MyForm_Deactivate(sender As Object, e As System.EventArgs) Handles Me.Deactivate
        Me.Hide()
    End Sub
It works great, except when the user clicks back to the main form, the main form is deactivated too and focus goes to some random other form.
I'm really not sure what's going on here or how to fix it, so any help would be appreciated.
 
Back
Top