Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to open last form in MDI application start
Message
From
17/04/2007 05:20:23
 
 
To
16/04/2007 12:04:46
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01216062
Message ID:
01216625
Views:
19
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform