How to close sub-form opened by showDialog()?

G

Guest

Hi all,

How to close a sub-form opened by showDialog()?

On the main form, I open a new form by using showDialog().
There is a Timer control on the main form, when Timer.Tick raises, the
program closes the sub-form and main form.
But now, the sub-form cannot be closed and the Me.close() rases error.

Private subForm as Form

Private Sub btnM_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnM.Click
Dim frm As New Form2(Me)
subForm = frm
frm.ShowDialog()
End Sub

Private Sub Logout(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
If Not subForm Is Nothing Then
subForm.Close()
End If
Me.Close()
End Sub

Thanks in advance.

Regards,
Alan
 
F

Fabien

Hi,

What is the error message?
Don't forget you must use Invoke to refresh a control from an other
thread than the one created the control.
In C# :
this.Invoke(new EventHandler(delegate
{
this.Close();
}));


BR

Fabien Decret
Windows Embedded Consultant

ADENEO (ADESET)http://www.adeneo.adetelgroup.com/
 

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

Similar Threads


Top