By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 910 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

Form Load not firing but form appears?

P: n/a
I have an odd issue going on with the calling of my forms. I have an
application that has a wizard. The wizard consists of about eight forms that
the user makes choices on. Each form has a "Back" and "Next" button. When
the user selects the "Next" button the form's user choices are saved to
variables and then the form is disposed and the next form called. The
problem is that when debugging I put a stopwatch on a form_load event on one
of the forms but the event never fires, even though the form appears on the
screen. How can this happen? I'm confused. IF it hit the back button the
next is still does the same thing. Even though the back button should also
dispose of the form. If I close the form with the "X" in the title bar then
go back through the wizard a second time, the form_load event fires. It's
almost like the form is already there or something. I have even added a
form.dispose() to the startup form for all of the forms in the wizard just
to try and get rid of them if they somehow already exist. Here is some of my
code:

Sub Main()

Dim frmSC as new frmSaveConfig

... much more code

End Sub

Public Class myForms

Private Shared m_frmSaveConfig As frmSaveConfig

Public Shared Property frmSaveConfig() As frmSaveConfig

Get

Return m_frmSaveConfig

End Get

Set(ByVal Value As frmSaveConfig)

m_frmSaveConfig = Value

End Set

End Property

... many more forms exist here

End Class

This is the code from the btn_Next click event of the calling form:

If frmSC Is Nothing OrElse frmSC.IsDisposed Then

frmSC = New frmSaveConfig

myForms.frmSaveConfig = frmSC

End If

ico.Dispose()

bm.Dispose()

Me.Dispose()

frmSC.ShowDialog()

Thanks,

John




Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
* "jcrouse" <me> scripsit:
I have an odd issue going on with the calling of my forms. I have an
application that has a wizard. The wizard consists of about eight forms that
the user makes choices on. Each form has a "Back" and "Next" button. When
the user selects the "Next" button the form's user choices are saved to
variables and then the form is disposed and the next form called. The
problem is that when debugging I put a stopwatch on a form_load event on one
of the forms but the event never fires, even though the form appears on the
screen.


Are you sure the event handler is connected to the event properly? Make
sure that there is a 'Handles MyBase.Load' appended to the handling
method's head.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2

P: n/a
You mean on the form I'm having problem with, like this:
Private Sub frmSaveConfig_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Thanks,
John
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2o************@uni-berlin.de...
* "jcrouse" <me> scripsit:
I have an odd issue going on with the calling of my forms. I have an
application that has a wizard. The wizard consists of about eight forms that the user makes choices on. Each form has a "Back" and "Next" button. When the user selects the "Next" button the form's user choices are saved to
variables and then the form is disposed and the next form called. The
problem is that when debugging I put a stopwatch on a form_load event on one of the forms but the event never fires, even though the form appears on the screen.


Are you sure the event handler is connected to the event properly? Make
sure that there is a 'Handles MyBase.Load' appended to the handling
method's head.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

P: n/a
John,

The form loads only the first time it is loaded, I have the idea you are
looking for the form activate event or what can be as well when that does
not do it either the form visible change event.

I hope this helps?

Cor
Nov 21 '05 #4

P: n/a
Cor,
I don't understand. First, how can the form possibly be displayed if the
form_load never fires. I put a stopwatch on it and it never fires, but the
form appears. Also, If I dispose of a form should the form_load event fire
the next time I call the form?

Thanks,
John

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OC*************@TK2MSFTNGP12.phx.gbl...
John,

The form loads only the first time it is loaded, I have the idea you are
looking for the form activate event or what can be as well when that does
not do it either the form visible change event.

I hope this helps?

Cor

Nov 21 '05 #5

P: n/a
John,

I was curious how I would do your problem, so I tried it with this sample.

I do not know if you can use it, the way I do it is called recursive.

It is debuggable however see that the sub is calling itself so that makes
debugging sometimes confusing.

When this does not help, show than some more of your code.

Cor
\\\2 forms with on form1 nothing and on form 2 a label, a textbox and 2
buttons 'in one of the buttons is the dialogresult.cancel property changed
in whatever
'however that is the next button
Private lastform As Integer
Private myformsar As New ArrayList
Private Sub Form1_Load(ByVal sender As Object, ByVal e _
As System.EventArgs) Handles MyBase.Load
lastform = 0
Do Until lastform = 7
If lastform = 0 Then
doforms(0)
Else
doforms(lastform - 1)
End If
Loop
MessageBox.Show(DirectCast(myformsar(7), info).text)
Me.Close()
End Sub
Private Sub doforms(ByVal formnumber As Integer)
Dim frm As New Form2
lastform = formnumber
frm.Label1.Text = (formnumber + 1).ToString
If myformsar.Count < formnumber + 1 Then
Dim myinfo As New info
myinfo.formnumber = formnumber
myinfo.text = "Myform" & formnumber.ToString
myformsar.Add(myinfo)
End If
frm.textbox1.Text = DirectCast(myformsar(formnumber), info).text
frm.Label1.Text = formnumber.ToString
If frm.ShowDialog = DialogResult.Cancel Then
frm.Dispose()
Exit Sub
Else
DirectCast(myformsar(formnumber), info).text = frm.textbox1.Text
frm.Dispose()
If lastform <> 7 Then
lastform += 1
doforms(lastform)
Else
Exit Sub
End If
End If
End Sub
End Class
Friend Class info
Friend text As String
Friend formnumber As Integer
End Class
///
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.