G
Guest
Public Class MainForm
Dim frm As DetailFrm '--frm is a Form Level variable
Private Sub MainForm_Load(...)
frm = Nothing
....
End Sub
Private Sub btnOpenDetail_Click(...)Handles btn.Click
If frm Is Nothing Then
frm = New frmDetailData
frm.Show()
Else
frm.BringToFront()
End If
End Sub
DetailFrm is not showdialog. It is basically a datasheet view of data
underlying MainForm. If frm Is Nothing, I instantiate it
frm = New frmDetailData
If frm is already running but is behind MainForm, when I click on
btnOpenDetail again - it will bring frm to the front. I don't want to
instantiate another copy of frm. The problem is that if I close frm
(DetailFrm) - by clicking on the red X at the top Right corner of the form,
and then click btnOpenDetail again - frm is still something/running so
frm.BringToFront() gets called but frm is not visible - does not appear.
In the frm.Disposed event I added Me.Dispose. But after closing frm - it
is still something/running. For this scenario - where frm is not showDialog,
what is the correct way to close/dispose frm? Is there a way to set it to
nothing from within the frm or will MainFrom need some poling mechanism that
checks a Property value from frm to see if the value = "YesRunning" or
"NoRunning" and if the value is "NoRunning" then set frm to frm = Nothing?
My current workAround is to set a Property Value in frm. If
frm.IsRunning.Equals(True) then frm.BringToFront(). If
frm.IsRunning.Equals(False) then I re-instantiate frm, but I believe it is
just another copy so now I have multiple copies running - but only one is
visible at a time. How to fix this?
Thanks,
Rich
Dim frm As DetailFrm '--frm is a Form Level variable
Private Sub MainForm_Load(...)
frm = Nothing
....
End Sub
Private Sub btnOpenDetail_Click(...)Handles btn.Click
If frm Is Nothing Then
frm = New frmDetailData
frm.Show()
Else
frm.BringToFront()
End If
End Sub
DetailFrm is not showdialog. It is basically a datasheet view of data
underlying MainForm. If frm Is Nothing, I instantiate it
frm = New frmDetailData
If frm is already running but is behind MainForm, when I click on
btnOpenDetail again - it will bring frm to the front. I don't want to
instantiate another copy of frm. The problem is that if I close frm
(DetailFrm) - by clicking on the red X at the top Right corner of the form,
and then click btnOpenDetail again - frm is still something/running so
frm.BringToFront() gets called but frm is not visible - does not appear.
In the frm.Disposed event I added Me.Dispose. But after closing frm - it
is still something/running. For this scenario - where frm is not showDialog,
what is the correct way to close/dispose frm? Is there a way to set it to
nothing from within the frm or will MainFrom need some poling mechanism that
checks a Property value from frm to see if the value = "YesRunning" or
"NoRunning" and if the value is "NoRunning" then set frm to frm = Nothing?
My current workAround is to set a Property Value in frm. If
frm.IsRunning.Equals(True) then frm.BringToFront(). If
frm.IsRunning.Equals(False) then I re-instantiate frm, but I believe it is
just another copy so now I have multiple copies running - but only one is
visible at a time. How to fix this?
Thanks,
Rich