RV.
RV.

Reputation: 2842

bring the last loaded controls back when i restart the machine

I am working in video application in my application am using many controls for user friendly first i will Load the base from only after that i ll load the other controls based on user need.... here my need is if user load ten controls in this case if he shutdown the machine means when he restart the machine i need to bring the all controls back what he was load the controls before he shutdown. thanks in advance

is there is any possible to achive this without store the current control set, and positions etc..

Upvotes: 5

Views: 118

Answers (2)

Tuomas Hietanen
Tuomas Hietanen

Reputation: 5303

How about making extension methods to Control class? (Actually, appropriate .NET abstract base class, a sub-class of Control class, depending on UI. Do you use Windows Forms or XAML or ASP.NET?)

Something like:

public static class MyPositionExtensions{
    public static void SaveState(this Control c){ /* Save position to xml-file */ }
    public static void RestoreState(this Control c){ /* Load from xml-file */ }
}

Then in your closing just loop like

foreach(var c in MyControls)c.SaveState();

and opening like

foreach(var c in MyControls)c.RestoreState();

Upvotes: 2

Adriaan Stander
Adriaan Stander

Reputation: 166336

You need to look at something like

Basically what it boils down to, is that you need a way to store the current control set, and positions (possibly values too) to some sort of storage (XML file, Registry, Database) when the user exits your form/application.

Then once they reopen the form/application, you need to retrieve these settings for the given user (if any is available) and restore the form/application to that state.

Upvotes: 3

Related Questions