Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ShowDialog causes Form Load method not to run
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00750040
Message ID:
00750665
Vues:
15
Hi Samuel,

My guess is that you are using an ActiveX control on your form. There is a known issue with the Load event not firing when calling ShowDialog to show a form that contains an ActiveX control. Here is the KB article that discusses the bug

http://support.microsoft.com/default.aspx?scid=kb;en-us;318386

Here is improved code over what the KB article recommends for a work-around:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
   Const WM_SHOWWINDOW = &H18
   Static m_loaded As Boolean

   If m.Msg = WM_SHOWWINDOW Then
      ' The form is being loaded
      If Me.Modal And Not m_loaded Then
         ' the form is modal and this is the first time it is being loaded
         MyBase.OnLoad(New System.EventArgs())
      End If
      ' remember we did it once
      m_loaded = True
   End If
   ' delegate to the default window procedure
   MyBase.WndProc(m)
End Sub
>
>The issue:
>
>I have a VB.NET Windows Form.  This form is invoked from a DBI.NET calendar control.
>If I invoke the form using <form>.Show, the load method of the form runs.
>If I invoke the form using <form>.ShowDialog, the load method will not run.
>
>What gives?
>
>On this one form, it was working fine initially, I made a change to 'DIM'
>a new variable, and bang, the load would no longer run if I invoked
>the form with 'ShowDialog'
>
>Any help would be appreciated.
>
>SAA
>
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform