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 3 14459
On Apr 27, 12:52 pm, Rich <R...@discussions.microsoft.comwrote:
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
Rich,
Just let the mainform handle the frm.Closed event.
Private Sub btnOpenDetail_Click(...)Handles btn.Click
If frm Is Nothing Then
frm = New frmDetailData
addhandler frm.FormClosed, addressof Me.frm_Closed
frm.Show()
Else
frm.BringToFront()
End If
End Sub
private sub frm_Closed (byval sender....)
removehandler frm.formclosed, addressof me.frm_closed
frm = nothing
end sub
--
Tom Shelton
Thanks. That worked perfectly. For posterity - here is what I did
Private Sub frm_Closed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs)
frm = Nothing
End Sub
The trick was to get the correct set of event args - which I got from the
FormClosed Event
Thanks again.
"Tom Shelton" wrote:
On Apr 27, 12:52 pm, Rich <R...@discussions.microsoft.comwrote:
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
Rich,
Just let the mainform handle the frm.Closed event.
Private Sub btnOpenDetail_Click(...)Handles btn.Click
If frm Is Nothing Then
frm = New frmDetailData
addhandler frm.FormClosed, addressof Me.frm_Closed
frm.Show()
Else
frm.BringToFront()
End If
End Sub
private sub frm_Closed (byval sender....)
removehandler frm.formclosed, addressof me.frm_closed
frm = nothing
end sub
--
Tom Shelton
Rich,
I am always curious why people want to spent time to close or finalize
something earlier than strictly needed. Maybe you have an explanation for
that. That one that is busy to finalize is surely not taken if you have
created a new one.
Cor
"Rich" <Ri**@discussions.microsoft.comschreef in bericht
news:32**********************************@microsof t.com...
Thanks. That worked perfectly. For posterity - here is what I did
Private Sub frm_Closed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs)
frm = Nothing
End Sub
The trick was to get the correct set of event args - which I got from the
FormClosed Event
Thanks again.
"Tom Shelton" wrote:
>On Apr 27, 12:52 pm, Rich <R...@discussions.microsoft.comwrote:
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
Rich,
Just let the mainform handle the frm.Closed event. Private Sub btnOpenDetail_Click(...)Handles btn.Click If frm Is Nothing Then frm = New frmDetailData addhandler frm.FormClosed, addressof Me.frm_Closed frm.Show() Else frm.BringToFront() End If End Sub
private sub frm_Closed (byval sender....) removehandler frm.formclosed, addressof me.frm_closed frm = nothing end sub
-- Tom Shelton
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pablo Salazar |
last post by:
Hi people!!.
Which is diference between to use method CLOSE and DISPOSE to close a form?
Tx.
Pablo Salazar
|
by: Nathan |
last post by:
I know this has been asked previously, but I've run into a situation where I
need to know the difference between close and dispose, and I can't get the
information I need from msdn help or previous...
|
by: Aaron Ackerman |
last post by:
I have been having just on going problems with my MS Datagrids. I have NO
idea what I am doing wrong.
What is esentially happening is that say I have three records in my Dataset.
I click on the...
|
by: Dennis |
last post by:
Ok, I'm trying to dispose of every object that I create that has a dispose
method based on advice from this newsgroup. However, I'm not sure how to
dispose of the following object that was created...
|
by: Deepak C.G via .NET 247 |
last post by:
I want to dispose the image object in my child form, unless I won't dispose this
object i can't delete the image file in my folder.
I get this error in MDIparent form
"An unhandled exception...
|
by: Geoff Callaghan |
last post by:
I have several functions that require doing a New on a local object. If the
object is local to a sub or function, do I need to dispose of it, or will
it just go away like any other local variable?...
|
by: Joe |
last post by:
Hello All:
Can anyone tell me what the difference is between the Close method of the
OleDbCommand object and the Dispose method of the OleDbCommand object?
TIA,
--
Joe
...
|
by: Smokey Grindle |
last post by:
I have a list box on my form, but I need to databind it to a data table that
is a private member of the form's class... so I basically have
Public Class MyForm
priate m_MyTable as new datatable...
|
by: rbrowning1958 |
last post by:
Hello,
I am confused by dispose etc. and hope someone can set me right.
1. The Dispose(Bool) the IDE generates for a form has nothing to do
with IDisposable, right?
2. So when is this called?...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |