Is form still loaded

  • Thread starter Thread starter Jack Russell
  • Start date Start date
J

Jack Russell

I have the following simple piece of code.

How can I test if the form I show is still loaded?

Thanks


Private Sub mnuAnalysisResults_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuAnalysisResults.Click
Dim AFormReport As New frmAnalysisResults
AFormReport.Show()


End Sub
 
Hi,

I would make AFormReport a form level variable.

Dim AFormReport As New frmAnalysisResults

Private Sub mnuAnalysisResults_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuAnalysisResults.Click
If AFormReport is nothing then
' needs to be reloaded
AFormReport = new frmAnalysisResults
End If

AFormReport.Show()
End Sub

Ken
----------------------
I have the following simple piece of code.

How can I test if the form I show is still loaded?

Thanks


Private Sub mnuAnalysisResults_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuAnalysisResults.Click
Dim AFormReport As New frmAnalysisResults
AFormReport.Show()


End Sub
 
Jack,
Dim AFormReport As New frmAnalysisResults
AFormReport.Show()

Now you are sure that the object exist because you created it before the
show as a complete new form.

For what you probably need (the form is than instanced globaly in the class)
see the sample from Ken.

Cor
 
Cor said:
Jack,




Now you are sure that the object exist because you created it before the
show as a complete new form.

For what you probably need (the form is than instanced globaly in the class)
see the sample from Ken.

Cor
Thanks to you both for your help
 
Jack,

Jack Russell said:
How can I test if the form I show is still loaded?
[...]
Private Sub mnuAnalysisResults_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuAnalysisResults.Click
Dim AFormReport As New frmAnalysisResults
AFormReport.Show()
End Sub

=>

\\\
Private m_ReportForm As ReportForm
..
..
..
If m_ReportForm Is Nothing OrElse m_ReportForm.IsDisposed Then
m_ReportForm = New ReportForm()
m_ReportForm.Show()
Else
m_ReportForm.Activate()
End If
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top