My.Settings

k3n51mm

Active member
Joined
Mar 7, 2007
Messages
40
Programming Experience
3-5
I need to reload the most recently used control in a panel after program shutdown and restart. The panel in question holds a series of form instances as part of a wizard. If the user closes the app, I need to reload the last form showing in the panel (I am not concerned here with persisting data the user has entered).

How can I store something in My.settings that will allow this? I tried just storing the form as a form (hehe), but I guess if I must go that route I'll get roped into binary formatting and serialization and stuff. Been searching for this for 1/2 day and now my brain hurts.

If I just store the name of the form's class as a string, how can I use that to create a new instance of it at restart, and load it into the panel? I can't convert a String type into a Form type.

For example, where the setting Name, Type, Scope and Value are WizScrn, String, User, [no default]

THANKS
 
Just store a string containing the form's name or a related keyword.

When you load up, use a select case something like this

VB.NET:
Select Case My.Settings.LastOpenFormName
  Case "FormA"
    ' Load Form A here...
  Case "FormB"
    ' Load Form B here...
  Case "FormC"
    ' Load Form C here...
End Select
 
Thanks for the responses.

cjard- sure, no problem, Forms are controls like any other. At design time, set TopLevel property to False - this enables it to be added to a container. In code, create an instance, and load it. Simple.


B2-That's exactly what I ended up doing; storing a string with the form's class name and sending it to a Loader class.
 
Thanks for the responses.

cjard- sure, no problem, Forms are controls like any other. At design time, set TopLevel property to False - this enables it to be added to a container. In code, create an instance, and load it. Simple.

Hmm.. It sounds like MDI, but you didnt appear to be using it

B2-That's exactly what I ended up doing; storing a string with the form's class name and sending it to a Loader class.
Why use a select case, when your panel has a .Controls collection that can take a name of a form?

panel.Controls(My.Settings.LastForm).Visible = true
 
Back
Top