I have a WinForms app that needs to take user input on open - before the
FormMain is displayed.

On the Form Load event of FormMain, I test for existence of an Access
database:

if (!File.Exists(Application.StartupPath +
"\\myAccess.mdb"))

If the mdb is not there, I need to open an input dialog form (with some
additional options) for selecting a different mdb:

FormDialogDifferentDatabase frmDialog =
new FormDialogDifferentDatabase();
frmDialog.Show();

How do I suspend execution of the code in the FormMain while the user
selects a different database? FormMain requires access to the database, so
I don't want to initialize it until it has a database. Should I put this
code in the constructor of FormMain?

Also, how do I get the user input from FormDialogDifferentDatabase? Do I
use DialogResult? I looked for examples of this but still confused...

Thanks in advance.

Re: newbie: Basic input dialog? by Brian

Brian
Mon Jul 18 13:47:11 CDT 2005

Open a form using .ShowDialog or if you use a OpenFileDialog control, it
will suspend code.

if File.Exists(Application.StartupPath +"\\myAccess.mdb") Then
'do your stuf...
else
dim OpenFileDialog1 as OpenFileDialog
With OpenFileDialog1
.InitialDirectory = "C:\"
.Filter = "All Files|*.*|DataBase|*.mdb|"
.FilterIndex = 2
End With
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim FilePath As String
FilePath = OpenFileDialog1.FileName
else
'Opps, didn't find the database so bail out
End If

>


"deko" <deko@nospam.com> wrote in message
news:qxvCe.38$NU2.35@newssvr13.news.prodigy.com...
>I have a WinForms app that needs to take user input on open - before the
>FormMain is displayed.
>
> On the Form Load event of FormMain, I test for existence of an Access
> database:
>
> if (!File.Exists(Application.StartupPath +
> "\\myAccess.mdb"))
>
> If the mdb is not there, I need to open an input dialog form (with some
> additional options) for selecting a different mdb:
>
> FormDialogDifferentDatabase frmDialog =
> new FormDialogDifferentDatabase();
> frmDialog.Show();
>
> How do I suspend execution of the code in the FormMain while the user
> selects a different database? FormMain requires access to the database,
> so I don't want to initialize it until it has a database. Should I put
> this code in the constructor of FormMain?
>
> Also, how do I get the user input from FormDialogDifferentDatabase? Do I
> use DialogResult? I looked for examples of this but still confused...
>
> Thanks in advance.
>
>