Why doesn't load event fire when i use form.showialog()?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a login form which I want to display with the showdialog method. When I do that the event handler for the load event does not run. If I use the show method the load event handler runs perfectly. I can't find any documentation regarding the load event not firing when a form is displayed using the showdialog method.
 
Engineerik,
I use ShowDialog and my Load event fires.

Can you attach a 15 to 20 line sample program that demostrates the problem.

Hope this helps
Jay

Engineerik said:
I have a login form which I want to display with the showdialog method.
When I do that the event handler for the load event does not run. If I use
the show method the load event handler runs perfectly. I can't find any
documentation regarding the load event not firing when a form is displayed
using the showdialog method.
 
Jay,
I have a breakpoint in the load event handler on the line that writes to the console. That breakpoint is not encountered if the showdialog method is used but it is when the show method is used.

You can see from the console output that the write does not occur after the showdialog method is used.

I appreciate any suggestions you might have on this.

Jay B. Harlow said:
Engineerik,
I use ShowDialog and my Load event fires.

Can you attach a 15 to 20 line sample program that demostrates the problem.

Hope this helps
Jay
Here is a code snippet and the console output I got.
The following code is in sub main() which is the startup object
Friend WithEvents frmSplash As New BInitSplash()
Friend WithEvents frmMain As New frmBInitMain()
[snip]
'Display the Splash Form
Console.WriteLine("frmSplash.showdialog")
bContinue = frmSplash.ShowDialog()

'Display without showmodal
Console.WriteLine("Now frmsplash.show")
frmSplash.Show()

Here is the load event handler of the form:
Private Sub BInitSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Console.WriteLine(Me.Name & " load event is firing.")
'Fill in controls as necessary
cbRemember.Checked = bRemember

If bRemember Then
tbUserName.Text = sUserName
tbPassword.Text = sPassword
tbDatabaseName.Text = sDatabaseName
tbServerLocation.Text = sServerLocation
End If

End Sub

Here is the console output:
[snip]
'BInitPro.exe': Loaded 'c:\windows\assembly\gac\microsoft.visualbasic\7.0.3300.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll', No symbols loaded.
frmSplash.showdialog
Now frmsplash.show
BInitSplash load event is firing.
'BInitPro.exe': Loaded 'c:\erix\work\binitpro\bin\interop.scripting.dll', No symbols loaded.
[snip]
 
I just created a new project from scratch that just displays a blank form and the load event is firing for both the show and showdialog methods.
I don't know how I managed to mangle the project I was working on but since I wasn't that deep into it I am going to start over with a clean slate and see what happens.

I will report more on this thread after I recreate the project from scratch.

Regards,
Engineerik

Engineerik said:
Jay,
I have a breakpoint in the load event handler on the line that writes to the console. That breakpoint is not encountered if the showdialog method is used but it is when the show method is used.

You can see from the console output that the write does not occur after the showdialog method is used.

I appreciate any suggestions you might have on this.

Jay B. Harlow said:
Engineerik,
I use ShowDialog and my Load event fires.

Can you attach a 15 to 20 line sample program that demostrates the problem.

Hope this helps
Jay
Here is a code snippet and the console output I got.
The following code is in sub main() which is the startup object
Friend WithEvents frmSplash As New BInitSplash()
Friend WithEvents frmMain As New frmBInitMain()
[snip]
'Display the Splash Form
Console.WriteLine("frmSplash.showdialog")
bContinue = frmSplash.ShowDialog()

'Display without showmodal
Console.WriteLine("Now frmsplash.show")
frmSplash.Show()

Here is the load event handler of the form:
Private Sub BInitSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Console.WriteLine(Me.Name & " load event is firing.")
'Fill in controls as necessary
cbRemember.Checked = bRemember

If bRemember Then
tbUserName.Text = sUserName
tbPassword.Text = sPassword
tbDatabaseName.Text = sDatabaseName
tbServerLocation.Text = sServerLocation
End If

End Sub

Here is the console output:
[snip]
'BInitPro.exe': Loaded 'c:\windows\assembly\gac\microsoft.visualbasic\7.0.3300.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll', No symbols loaded.
frmSplash.showdialog
Now frmsplash.show
BInitSplash load event is firing.
'BInitPro.exe': Loaded 'c:\erix\work\binitpro\bin\interop.scripting.dll', No symbols loaded.
[snip]
 
It sounds like your "Form_Load" proc in your code lost its "Handles
MyBase.Load" directive at the end. They're easy to miss.

Engineerik said:
I just created a new project from scratch that just displays a blank form
and the load event is firing for both the show and showdialog methods.
I don't know how I managed to mangle the project I was working on but
since I wasn't that deep into it I am going to start over with a clean slate
and see what happens.
I will report more on this thread after I recreate the project from scratch.

Regards,
Engineerik
the console. That breakpoint is not encountered if the showdialog method is
used but it is when the show method is used.
You can see from the console output that the write does not occur after the showdialog method is used.

I appreciate any suggestions you might have on this.

Jay B. Harlow said:
Engineerik,
I use ShowDialog and my Load event fires.

Can you attach a 15 to 20 line sample program that demostrates the problem.

Hope this helps
Jay
Here is a code snippet and the console output I got.
The following code is in sub main() which is the startup object
Friend WithEvents frmSplash As New BInitSplash()
Friend WithEvents frmMain As New frmBInitMain()
[snip]
'Display the Splash Form
Console.WriteLine("frmSplash.showdialog")
bContinue = frmSplash.ShowDialog()

'Display without showmodal
Console.WriteLine("Now frmsplash.show")
frmSplash.Show()

Here is the load event handler of the form:
Private Sub BInitSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Console.WriteLine(Me.Name & " load event is firing.")
'Fill in controls as necessary
cbRemember.Checked = bRemember

If bRemember Then
tbUserName.Text = sUserName
tbPassword.Text = sPassword
tbDatabaseName.Text = sDatabaseName
tbServerLocation.Text = sServerLocation
End If

End Sub

Here is the console output:
[snip]
'BInitPro.exe': Loaded
'c:\windows\assembly\gac\microsoft.visualbasic\7.0.3300.0__b03f5f7f11d50a3a\
microsoft.visualbasic.dll', No symbols loaded.
frmSplash.showdialog
Now frmsplash.show
BInitSplash load event is firing.
'BInitPro.exe': Loaded 'c:\erix\work\binitpro\bin\interop.scripting.dll', No symbols loaded.
[snip]
 
After reading one of your latter posts, I see that's not your problem. Sorry
for that.
Though I'm curious about the
"'c:\erix\work\binitpro\bin\interop.scripting.dll', No symbols loaded." Is
that library standard fare? I've seen some strange (similar) "non-errors"
happen with interop.

It sounds like your "Form_Load" proc in your code lost its "Handles
MyBase.Load" directive at the end. They're easy to miss.

Engineerik said:
I just created a new project from scratch that just displays a blank
form
and the load event is firing for both the show and showdialog methods.
I don't know how I managed to mangle the project I was working on but
since I wasn't that deep into it I am going to start over with a clean slate
and see what happens.
I will report more on this thread after I recreate the project from scratch.

Regards,
Engineerik
to
the console. That breakpoint is not encountered if the showdialog method is
used but it is when the show method is used. after
the showdialog method is used.
I appreciate any suggestions you might have on this.

:

Engineerik,
I use ShowDialog and my Load event fires.

Can you attach a 15 to 20 line sample program that demostrates the problem.

Hope this helps
Jay

Here is a code snippet and the console output I got.
The following code is in sub main() which is the startup object
Friend WithEvents frmSplash As New BInitSplash()
Friend WithEvents frmMain As New frmBInitMain()
[snip]
'Display the Splash Form
Console.WriteLine("frmSplash.showdialog")
bContinue = frmSplash.ShowDialog()

'Display without showmodal
Console.WriteLine("Now frmsplash.show")
frmSplash.Show()

Here is the load event handler of the form:
Private Sub BInitSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Console.WriteLine(Me.Name & " load event is firing.")
'Fill in controls as necessary
cbRemember.Checked = bRemember

If bRemember Then
tbUserName.Text = sUserName
tbPassword.Text = sPassword
tbDatabaseName.Text = sDatabaseName
tbServerLocation.Text = sServerLocation
End If

End Sub

Here is the console output:
[snip]
'BInitPro.exe': Loaded
'c:\windows\assembly\gac\microsoft.visualbasic\7.0.3300.0__b03f5f7f11d50a3a\
microsoft.visualbasic.dll', No symbols loaded.
frmSplash.showdialog
Now frmsplash.show
BInitSplash load event is firing.
'BInitPro.exe': Loaded 'c:\erix\work\binitpro\bin\interop.scripting.dll', No symbols loaded.
[snip]
 
Back
Top