Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Ok, here's the problem. I have a form(a) which I am calling from another form(b). when form(a) is loaded i have a set of code that is set to run. Now form (a) is launced by double clicking on a chart in form (b) using forma.show.

 

The problem is this: form(a) only loads half the time.

 

Half the time I attempt to load form(a) the code set to run on load is activated and runs but does not show the form, the other half it shows the form but does not run the code. I am really confused. Any ideas?

 

Thanks

Posted
Showing some code might have been helpfull so we can see exactly whats going on. I suspect your problem is this. The OnLoad method is only called when the page is first loaded not everytime you call a forms .Show() method. Thus whenever you are creating the form and then calling Show() the OnLoad event is triggered. But if the object it already Initialised the OnLoad event isn't triggered.
Anybody looking for a graduate programmer (Midlands, England)?
Posted

Okay, that may explain part of the problem, but it isn't called on the first time and then not again. The code (ChartChangeForm_Load) runs every odd time that the .show command is ran through. In addition, the ChartChangeForm doesn't show. On the even times that I call the .show command, the form will show, but not run the code. I could see the Load function not being called because of your reasoning, but it doesn't even load up the form half the time.

 

Here's my code.

Private Sub TLeftChart_DblClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TLeftChart.DblClick
       ActiveControl.Tag = 1
       ChartChangeForm.Show()
End Sub
Private Sub ChartChangeForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim x As Int16
       For x = 0 To 3
           If chartset(x).Tag = 1 Then
               MsgBox("Yeah")
               chartset(x).Tag = Nothing
               Exit For
           End If
       Next
       Me.Datebox.Value = ddt
   End Sub

 

Each sub is in their related forms, I just grouped them here to show both.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...