Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to open last form in MDI application start
Message
De
17/04/2007 05:20:23
 
 
À
16/04/2007 12:04:46
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01216062
Message ID:
01216625
Vues:
17
Hi,

>>Another option *might* be to serialize the form - that way you could recreate it in pretty much the same state that it was in when it was closed....
>
>Viv,
>
>thank you.
>I have code in form constructor which re-creates form OK.
>So I simply need to call this form at application startup.
>
>I think about the following approach:
>
>1. Retrieve actual calling class name from base class constructor and store it in isolated storage (application can be run form web browser also).
>
>2. At startup retrieve form name and create mdi child from it using reflection.
>
>Where to find any sample code for this?

Leaving aside where you decide to store the information you can use something like the following to recreate the form:
string s = LastFormReference.GetType().FullName;
//Save s then on startup use it thus:
Form lf =   (Form) System.Activator.CreateInstance(Type.GetType(s));
But you wanted to retain parameter values as well and you can't pass parameters with CreateInstance which is why I suggested serializing the form. If you use XML serialization only public properties are serialized and since forms tend not to have a large public interface it should be easy to keep the XML pretty small.
HTH,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform