Dialog to close Main Form 
Author Message
 Dialog to close Main Form

I have a dialog box coming up before main form loads fully. Which is what I
want
Public Class frmMainWindow

Inherits System.Windows.Forms.Form

Private Sub frmMainWindow_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Logon As New frmLogonBox()
Logon.ShowDialog()

End Sub

End Class

 I want the Main form to quit loading and the program to end if the Person
chooses the cancel button of the Dialog Box. The btnClose_click event is the
cancel button. So far the frmMainWindow loads fully. How do I make it so it
does not load at all and the program quits? Your help is greatly
appreciated.

Public Class frmLogonBox

Inherits System.Windows.Forms.Form

Public Sub btnClose_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClose.Click

Me.Close()

MessageBox.Show("You cannot enter the program without a password!", "Cancel
Message", MessageBoxButtons.OK)

End Sub
End Class



Thu, 22 Sep 2005 19:50:48 GMT  
 Dialog to close Main Form
Add a module to your project.  Set the dialogresult property of the cancel
button to cancel.  Set the project to start with sub main.

Private sub Main()
dim LOGON as new frmLogin
dim dr as DialogResult

dr=LOGON.ShowDialog()
if dr <> dialogresult.cancel then
    .....Validate user
    .... Load the main form
end if
end sub

Ken
----------------------------------------------------------------------------
------

Quote:
> I have a dialog box coming up before main form loads fully. Which is what
I
> want
> Public Class frmMainWindow

> Inherits System.Windows.Forms.Form

> Private Sub frmMainWindow_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim Logon As New frmLogonBox()
> Logon.ShowDialog()

> End Sub

> End Class

>  I want the Main form to quit loading and the program to end if the Person
> chooses the cancel button of the Dialog Box. The btnClose_click event is
the
> cancel button. So far the frmMainWindow loads fully. How do I make it so
it
> does not load at all and the program quits? Your help is greatly
> appreciated.

> Public Class frmLogonBox

> Inherits System.Windows.Forms.Form

> Public Sub btnClose_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnClose.Click

> Me.Close()

> MessageBox.Show("You cannot enter the program without a password!",
"Cancel
> Message", MessageBoxButtons.OK)

> End Sub
> End Class



Thu, 22 Sep 2005 23:50:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Starting a form after Closing Sub Main

2. How to Keep Data In Dialog Form on Close

3. Print Dialog causes calling form to close unexpectedly

4. Dialog forms wont close during load event

5. Close a login dialog & open a form

6. Forms, primary thread closing when closing startup form

7. Form Close Button Does Not Close the Form

8. changing stuff in your main form from another form

9. Unhandled exception in system.windows.forms.dll (in my main form) - argh

10. Help altering main form from other forms

11. how to change properties of the main form from a another form

12. maximize child form display multiple tool box controls on main form

 

 
Powered by phpBB® Forum Software