ColdIce
New member
- Joined
- Apr 29, 2011
- Messages
- 1
- Programming Experience
- 1-3
Hello!
I got two forms: frmMain and frmSettings.
Application startup is set to: frmMain.
I got the following code @ frmMain Load:
And this code for frmSettings Form Closing:
I'm not sure if this is the right way to do it. I want like to check if a file exist on main form, if not: force open settings form. And then when the user is closing the form with exit button = check if the file exist again. If it doesn't exist, close application.
It's a huge application and I need optimized on most parts.
Also, the settings form is asking the closing question two times
I got two forms: frmMain and frmSettings.
Application startup is set to: frmMain.
I got the following code @ frmMain Load:
VB.NET:
settings.DatabasePath = Application.StartupPath & "\"c & "application.db3"
If (File.Exists(settings.DatabasePath)) Then
LoadUserSettings()
Else
frmsettings.ShowDialog()
End If
And this code for frmSettings Form Closing:
VB.NET:
If (Not File.Exists(settings.DatabasePath)) Then
If (MessageBox.Show("Are you sure you want to exit without saving?", "Exit?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) = Windows.Forms.DialogResult.Yes) Then
System.Windows.Forms.Application.Exit()
Else
e.Cancel = True
End If
frmmain.LoadUserSettings()
End If
I'm not sure if this is the right way to do it. I want like to check if a file exist on main form, if not: force open settings form. And then when the user is closing the form with exit button = check if the file exist again. If it doesn't exist, close application.
It's a huge application and I need optimized on most parts.
Also, the settings form is asking the closing question two times