Bobski Bobski - 1 year ago 144 Question

Enabling/disabling MDiParent form after closing a .showDialog() form

I currently have a form that is declared as NewMDIChild = frm1. Within frm1 i open a new form that is about 1/3 of the size of frm1 - this forms name is frmX. This is how I open it....

Me.Enabled = False
'Pass globals to be used in search query

Dim frmX As New FrmX()

So I include this code with a button_Click on my Frm1. Everything works just fine. What I'm trying to do is on the button click on frm1 - I'm trying to disable frm1 - show frmX in .ShowDialog. On FrmX i have a CLOSE button, so that when user clicks CLOSE on it, I am able to enabled = true the frm1 that is in the background. I trying to do it on ACTIVATED event but it doesn't recognize it. How would I do something like that...

Not sure if i have to call a function or something from frmx or if there is an event in frm1 that can be used to enabled it. I tried GotFocus, MouseHove - nothing works

Answer Source

Once the form is disabled, most (if not all) the events are not going to fire. The next line to execute will be anything after the ShowDialog() so you can enable it there:

Me.Enabled = False
Using dlg As New FrmX
End Using
Me.Enabled = True

Note that when a form is shown using ShowDialog() it is not automatically disposed, so the code uses a Using block to do so.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download