Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto Load a Form
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00770013
Message ID:
00770095
Vues:
16
Hi Stephen,

I sounds like there is some dependency on the second form to the first form. What you can do is check to see if the form already exists in the MainForm_Activate by doing the following:
object x = mmApp.FormMgr.Get("MyFormClassName");
if (x==null)
{
   // Put you code here to create an instance of the form
   MessageBox.Show("Form not found");
}
else
{
   // This section is where the form is already instantiated
   MessageBox.Show("Form found");
}
>I am trying to load a form automatically each time I run the application. The form can also be run from a menu item. I tried to put the call into MainForm_Load or even the constructor of the MainForm, I always get "Object reference not set to an instance of an object" error somewhere deep inside the "Initialize Component" section of the child form. If I move my call to MainForm_Activate, it works but I get a new form everytime I alt-tab to another application and back.
>
>Here is the code I used:
>
>private void OpenCustomer()
>{
> frmCust = new CustomerForm();
> frmCust.MdiParent = this;
> frmCust.Show();
>}
>
>private void MainForm_Load(object sender, System.EventArgs e)
>{
> this.OpenCustomer();
>}
-----------------------------------------

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